in reply to end of file!

With a little help from the Perl Cookbook:

#!/usr/bin/perl -w use strict; my $filename = shift; my $line; open (FILE, "$filename") || die "Couldn't open file: $!\n"; do {$line = <FILE>} until eof; print "$line";
J. J. Horner
Linux, Perl, Apache, Stronghold, Unix
jhorner@knoxlug.org http://www.knoxlug.org/

Replies are listed 'Best First'.
RE: Re: end of file!
by mrt (Acolyte) on Jul 26, 2000 at 20:13 UTC
    Hi!! Your reply is workable but involves a long process.. as the seeker of wisdom has told in further comments that the file is too big, this method may take a lot of time as it has to read eachline again and again lines and check for eof.. which the seeker already does not wanted to do, as is very clear from his question. Also for programmes repeating this code again and again it may be really be unwanted way to read the last line.. yes perl cook book gives it just an example and does not recommends this as very good way to do the same job, infact it expects us to read the codes and use them in best possible ways depending upon situation ......