dusoo has asked for the wisdom of the Perl Monks concerning the following question:
file's data: 010 011 012 020 021
Thanks, Dusoocode: ... my $line_num=1; my $hash; while (<FH>) { chomp $_; my $line = $_; my @array = map { s/^\s+//; # strip leading spaces s/\s+$//; # strip tailing spaces $_ # return the modified string } split '\s+', $line; print $array[0]."\n"; # WORKS print $array[1]."\n"; # WORKS print @array."\n"; # prints number of elements instead of whole array $hash->{$line_num}=@array; # does not works because of previous issue $line_num++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help with split into array
by jwkrahn (Abbot) on Aug 17, 2011 at 08:04 UTC | |
|
Re: help with split into array
by Anonymous Monk on Aug 17, 2011 at 07:41 UTC |