Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Manually incrementing @ array during for

by tybalt89 (Monsignor)
on Mar 16, 2020 at 17:39 UTC ( [id://11114358]=note: print w/replies, xml ) Need Help??


in reply to Manually incrementing @ array during for

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11114346 use warnings; my @array = <DATA>; use Data::Dump 'dd'; dd \@array; my @combinedarray = (join "", @array, '') =~ /^.*\n(?: .*\n)*/gm; dd \@combinedarray; # do the 'for' over @combinedarray __DATA__ keyword1 data1 data2 data3 keyword2 data1 data2 data3 data4 data5 data6 keyword1 data1 data2 data3 data4 keyword3 data1

Outputs:

[ "keyword1 data1 data2 data3\n", "keyword2 data1 data2 data3\n", " data4 data5\n", " data6\n", "keyword1 data1 data2 data3 data4\n", "keyword3 data1\n", ] [ "keyword1 data1 data2 data3\n", "keyword2 data1 data2 data3\n data4 data5\n data6\n", "keyword1 data1 data2 data3 data4\n", "keyword3 data1\n", ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114358]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-28 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found