Home > Archive > PERL Beginners > June 2006 > Slurping a big file (WAS: Netiquette)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Slurping a big file (WAS: Netiquette)
|
|
| Dave Gray 2006-06-24, 8:01 am |
| On 6/23/06, Omega -1911 <1911que@gmail.com> wrote:
> Shawn, I modified your example like so, was this correct?
>
> chomp( my $data1 = <IN> ); # line 1
> chomp( my $data2 = <IN> ); # line 2
> chomp( my $data3 = <IN> ); # line 3
> chomp( my $data4 = <IN> ); # line 4
> chomp( my $data5 = <IN> ); # line 5
> while( <IN> ){
> chomp;
> push @past_bids, $_; # push remaining lines into array
> }
> close FILE;
You still haven't told us WHY you want to keep the entire rest of the
file you're reading in an array.
| |
| Dave Gray 2006-06-24, 6:58 pm |
| On 6/23/06, Omega -1911 <1911que@gmail.com> wrote:
> On 6/23/06, Dave Gray <yargevad@gmail.com> wrote:
>
> Actually, for this particular sub, I don't need the rest of the file and I
> wasn't sure of the best method to extract the first five lines without
> re-writing the file structure.
>
> Your advice is welcomed and I would appreciate any clues or insight on an
> efficient style of code.
Simply reading lines from a file does nothing to affect the file
itself, unless it happens to be a quantum file (ha ha), which it
isn't. You can omit the while loop and have exactly the same behavior
without wasting a lot of memory.
|
|
|
|
|