Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

( #160633=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How do I get the last occurrence of a word (or words) in a file? contributed by mslattery

Or stated another way ... arn't hashes great?

while (<>) { /^(.+)\:/ ; # Capture Server Name $hash{$1} = $_ ; # Create Hash Key if found } foreach $server (sort keys %hash) { print "$hash{$server}\n" ; }
Just for another style!

Have fun,
mslattery

Comment on Answer: How do I get the last occurrence of a word (or words) in a file?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2015-07-05 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls