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