in reply to Re^2: Store the outcome of a foreach loop in an array
in thread Store the outcome of a foreach loop in an array
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Store the outcome of a foreach loop in an array
by perl_5eeker (Novice) on Jan 10, 2019 at 23:25 UTC | |
by haukex (Archbishop) on Jan 11, 2019 at 08:05 UTC | |
by AnomalousMonk (Archbishop) on Jan 10, 2019 at 23:39 UTC | |
by LanX (Saint) on Jan 11, 2019 at 00:04 UTC |