"Elston, Jeremy" wrote:
>
> Greetings...
>
> Peter's solution is the one I would recommend unless you are reading large
> files and/or your system has little memory available. By reading into an
> array, the entire file will be pulled into memory. If memory use is an
> issue, you could use something like this:
>
> -----
>
> open(FILE, "my_file.txt") or die;
>
> $pos = -2; # Use this to get past EOF and last newline
This is non-portable. eg, DOS/Win32 uses a 2 byte line terminator
("\r\n" or "\015\012").
>
> while($char ne "\n")
> {
> seek FILE, $pos, 2;
> read FILE, $char, 1;
> $pos--;
> }
>
> $final = <FILE>;
> print "Last line is: $final\n";
--
-Tim Hammerquist <[EMAIL PROTECTED]>
A child of five would understand this.
Send someone to fetch a child of five.
-- Groucho Marx
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users