Re: Slurping a big file (WAS: Netiquette)

2006-06-24 Thread Dave Gray

On 6/23/06, Omega -1911 <[EMAIL PROTECTED]> wrote:

On 6/23/06, Dave Gray <[EMAIL PROTECTED]> wrote:
> On 6/23/06, Omega -1911 <[EMAIL PROTECTED]> wrote:
> > Shawn, I modified your example like so, was this correct?
> >
> > chomp( my $data1 =  ); # line 1
> > chomp( my $data2 =  ); # line 2
> > chomp( my $data3 =  ); # line 3
> > chomp( my $data4 =  ); # line 4
> > chomp( my $data5 =  ); # line 5
> > while(  ){
> >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.
>

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.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Slurping a big file (WAS: Netiquette)

2006-06-23 Thread Dave Gray

On 6/23/06, Omega -1911 <[EMAIL PROTECTED]> wrote:

Shawn, I modified your example like so, was this correct?

chomp( my $data1 =  ); # line 1
chomp( my $data2 =  ); # line 2
chomp( my $data3 =  ); # line 3
chomp( my $data4 =  ); # line 4
chomp( my $data5 =  ); # line 5
while(  ){
   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.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]