but it only saves "c3r1" and comes out of the loop
This would happen if @$lines only has a single element, "c1r1,c2r1,c3r1,c4r1,c5r1\nc1r2,c2r2,c3r2,c4r2,c5r2\nc1r3,c2r3,c3r3,c4r3,c5r3". As I showed here, please use Data::Dumper to print out $lines, as in: "use Data::Dumper; $Data::Dumper::Useqq=1; print Dumper($lines);". If that shows a single string with \n's in it, then my assumption is correct. Instead of doing something like using split on that string, it's probably better if we took a look at where you're getting $lines from - please have a look at Short, Self-Contained, Correct Example, a SSCCE would be useful so we can run the code for ourselves and see exactly the issue you're having.
In reply to Re^3: Store the outcome of a foreach loop in an array
by haukex
in thread Store the outcome of a foreach loop in an array
by perl_5eeker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |