develooper Front page | perl.beginners | Postings from December 2002

Re: file into memory

Thread Previous | Thread Next
From:
LRMK
Date:
December 24, 2002 09:15
Subject:
Re: file into memory
Message ID:
003201c2ab70$5f10d260$535e5ecb@lrmk

load the file in to the array @lines

then run following

chomp(@lines); # removes all the new lines

foreach $line (@lines){

#process $line


}



----- Original Message -----
From: "Schwedler Kofoed" <Schw_kof@mail.tele.dk>
To: <beginners@perl.org>
Sent: Tuesday, December 24, 2002 5:04 AM
Subject: file into memory


> Hi all,
>
> I would like to open a file with the content:
>
> peter 141444
> oscar e324345
> simon  j85547
>
> in a perl script - but instead of reading the file one line at a time I
> would like to suck the whole file into memory and processing each line
from
> there.
>
> I have tried to:
>
> open FILE, "< tmp.txt";
> @xx = <FILE>;
>     while  $file(@xx)    {
> ................
> }
>
> but I cant get it to work  - where did I go wrong ?
>
> Thanks!
>
> /Jakob
>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About