in reply to Adding hashes to already existing array
Echoing stevieb's comment, it would help if you could manually create an example of the structure that you are trying to build. Or maybe back up a bit and explain how you intend to use the structure and we can suggest some possibilities?use warnings; use Data::Dumper; $fc = 'abcdfoofrobnicatebardefforspambazghi'; $re2 = qr/(fo.)(.*?)(ba.)/; my @excerpts; push @excerpts, [$1,$2,$3] while $fc =~ /$re2/g; print Dumper \@excerpts; # Simple iteration over the Array of Array (AoA) # for each row break this down into names that make sense # for your data, whatever they are.. use those names # instead of indicies to process the data. foreach my $rowref (@excerpts) { my($namea,$nameb,$namec) = @$rowref; print "first=$namea second=$nameb third=$namec\n"; } __END__ $VAR1 = [ [ 'foo', 'frobnicate', 'bar' ], [ 'for', 'spam', 'baz' ] ]; first=foo second=frobnicate third=bar first=for second=spam third=baz
Update: added how to use AoA to the code above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Adding hashes to already existing array
by ExReg (Priest) on May 06, 2016 at 20:32 UTC |