> -----Original Message-----
> From: Schwedler Kofoed [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 23, 2002 6:04 PM
> To: [EMAIL PROTECTED]
> 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'm not sure what that accomplishes for you, but...
>
> I have tried to:
>
> open FILE, "< tmp.txt";
You need to check for errors on open.
> @xx = <FILE>;
That's OK; it will read the entire file into the array, but you should add
"use strict;" at the top of your script and use "my" to declare @xx.
> while $file(@xx) {
You're confusing the syntax of while() and foreach()
You want:
for my $file (@xx) {
}
> ................
> }
>
> but I cant get it to work - where did I go wrong ?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]