if this is what you want:
while (<HANDLE>) { $string .= $_ }
you'll want to concider using this instead:
{ local $/; $in = <HANDLE> }
which will put the entire contents of HANDLE into $in (by undeffing $/, which
is holds the line seperator character - it will be restored once the block
exits)
but like genie said, carefull you dont read in *too* much into memory, cuz it
will kill your PC
if your intent is something like this:
"if a certain line in the file contains 'foo', print it to a log file" then
this:
while (<HANDLE>) { if(/foo/) { print LOG "$. holds $_" } }
which will be a lot safer and kinder to your memory then:
@foo = <HANDLE>;
for (@foo) { if (/foo/) { print LOG "$. holds $_" } }
since the first doesnt require the entire file to be read into memory first
hope this helps,
Jos Boumans
"Evgeny Goldin (aka Genie)" wrote:
> > I am trying to read a quite large file (ca 13000 lines) directly into an
> > array (for speed)
>
> while ( <HANDLE> ){..}
>
> is the best way for reading large files, I think.