Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Find last line in Text file parsing

by biohisham (Priest)
on Oct 04, 2010 at 06:21 UTC ( [id://863263]=note: print w/replies, xml ) Need Help??


in reply to Find last line in Text file parsing

You're opening a file twice, that may not be necessary if you reconstruct your code to use the eof function to detect the end of the file, there is a difference between eof and eof() however and the later will only detect the end of the last file in a list of files provided whereas eof -without the parentheses- can detect the end of each file ...
use strict; use warnings; while(<DATA>){ if(eof){ #Check if the last line has ' last ' print ~/\slast\s/ ? 'yes' : 'no'; } } __DATA__ one line two lines three lines this is the last one

Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Log In?
Username:
Password:

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

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

    No recent polls found