in reply to Re^3: Store the outcome of a foreach loop in an array
in thread Store the outcome of a foreach loop in an array
Here is SSCCE
And you were right - @$lines with Data::Dumper printed the following output: $VAR1 = "c1r1,c2r1,c3r1,c4r1,c5r1\nc1r2,c2r2,c3r2,c4r2,c5r2\nc1r3,c2r3,c3r3,c4r3,c5r3" ;#!/usr/bin/perl use customlib; my $file = 'cr.csv'; my $lines; rdfile($file,\$lines); # Remove comments and blank lines @$lines = grep(!/^\s*#/,@$lines); @$lines = grep(!/^\s*$/,@$lines); @$lines = join "\n", @$lines; my @store; foreach my $line (@$lines) { my @val = split(/\,/,$line); push (@store,$val[2]); } #printf "@store\n"; use Data::Dumper; $Data::Dumper::Useqq=1; print Dumper($lines);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Store the outcome of a foreach loop in an array
by haukex (Archbishop) on Jan 11, 2019 at 08:05 UTC | |
|
Re^5: Store the outcome of a foreach loop in an array
by AnomalousMonk (Archbishop) on Jan 10, 2019 at 23:39 UTC | |
|
Re^5: Store the outcome of a foreach loop in an array
by LanX (Saint) on Jan 11, 2019 at 00:04 UTC |