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

Re: Finding a Letter at Last line

by davidrw (Prior)
on Nov 08, 2006 at 16:17 UTC ( [id://582907]=note: print w/replies, xml ) Need Help??


in reply to Finding a Letter at Last line

TWTOWTDI :)
perl -lne '$s=$_; END{ print "OK" if $s=~/^T/ }' /tmp/foo
Though you might want exit codes instead, depending on what's calling this
perl -ne '$s=$_; END{ exit($s=~/^T/ ? 0 : 1) }' /tmp/foo
Or, using File::Tie:
perl -MTie::File -e 'tie @f, "Tie::File", shift; exit 1 unless $f[-1] +=~ /^T/' /tmp/foo
Or, using File::ReadBackwards (untested):
perl -MFile::ReadBackwards -e 'exit 1 unless File::ReadBackwards->new( +shift)->readline =~ /^T/' /tmp/foo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-29 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found