Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How do I get the last occurrance of a word (or words) in a file?

by merlyn (Sage)
on May 11, 2000 at 02:13 UTC ( [id://11084]=note: print w/replies, xml ) Need Help??


in reply to How do I get the last occurrence of a word (or words) in a file?

By getting the "last" occurrance, I don't know if you want to know the line it's on (as a line number), or the contents of the line. So I'll do both:
while (<>) { if /^((VIS|JIT|MAD)HU2?):/) { $found{$1} = [$., $_]; } } for (sort keys %found) { print "$_ => @{$found{$_}}\n"; }
season to taste.

Log In?
Username:
Password:

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

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

    No recent polls found