in reply to Splitting text into arrays
How about:
use Data::Dumper; open(DAT, "< file") or die $!; while(<DAT>) { chomp; push @data, [ split( /,/ ) ]; # or split( /,/, $_ ) } print Dumper \@data;
The while loop reads line by line, so it takes care about the splitting on newlines already.
The split on comma is inside square brackets - these create an anonymous array around the results of split.
That array is pushed on @data.
Cheers, Sören
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting text into arrays
by perl_seeker (Scribe) on Jun 13, 2004 at 07:51 UTC | |
|
Re^2: Splitting text into arrays
by perl_seeker (Scribe) on Jun 13, 2004 at 07:51 UTC |