[EMAIL PROTECTED]:
>
> Hi,
>
> I have an ASCII file, running in DOS.
> It is not a fixed file length.
> Its lines of data have various lengths. (some lines are empty).
>
> The program reads line by line(<FILE>), and processes the lines.
> At a certain line I need to read the next line,
> check what its contents are, and then readjust
> the file pointer back to the first line. Since its not a fixed length, its
> difficult using seek().
>
> Here's the basic code
>
> sub read_content {
> ## Read next line and jump back
>
> $_ = <IN>; ## Read the next line
> $len_record = length($_) + 1; # get the record length + 1 for
> carriage return
>
> seek(IN, -($len_record),1); ## Go back up one line
>
> }
>
> It's not going back correctly or at all.
> Any help is appreciated
You want to read a file backward and
the file is to long to make the trick:
my @lines = reverse (<IN>);
Then there's a cpan module
File::ReadBackwards
which does it for you.
Best Wishes,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]