Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: end of file!

by jjhorner (Hermit)
on Jul 26, 2000 at 19:38 UTC ( [id://24510]=note: print w/replies, xml ) Need Help??


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 ......

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://24510]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-24 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found