in reply to Store the outcome of a foreach loop in an array

Note: This is the type of transform that map was designed for.
use strict; use warnings; my $lines = [ "c1r1,c2r1,c3r1,c4r1,c5r1\n", "c1r2,c2r2,c3r2,c4r2,c5r2\n", "c1r3,c2r3,c3r3,c4r3,c5r3\n", ]; my @store = map {(split /,/)[2]} @$lines; local $, = ",\n"; print @store;
Bill