At 11:13 PM 5/16/01 +0200, Paul Johnson wrote:
>On Wed, May 16, 2001 at 11:34:26AM -0700, Peter Scott wrote:
> > At 12:32 AM 5/17/01 +0500, Tirthankar C.P wrote:
> > >What is the simplest way to read in a matrix, say
> >
> > my @matrix;
> > while (<>) {
> > push @matrix, [ split ];
> > }
>
>Without wishing to turn this into FWP (too much), and noting the request
>was for the simplest solution, may I submit the following as a simpler
>method, maybe even the simplest.
>
>my @matrix = map [split], <>;
>
>Although I suppose it depends a bit on your idea of simplicity ....
And on your idea of performance, since that will read all of the lines into
memory before performing the map, thus increasing the memory needed, which
might be an issue for large input files.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com