On 8/24/07, Pat Rice <[EMAIL PROTECTED]> wrote:

> open (DATA, "$data_file") or die "can't open $data_file $!";
> my @array_of_data = <DATA>;

That reads the entire file into the array.

> while ($line = <DATA>)

That goes back to try to read more, but you're already at end-of-file.
So it won't find anything.

If you want to re-read the file, you could re-open it first, since
that resets the read position to the start of the file. Or you could
move the position directly by using seek().

But you probably don't need to re-read the file, since you have the
data in memory. Change the while loop to a foreach loop and you can
avoid doing the I/O twice:

  foreach my $line (@array_of_data) {
    ....

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to