Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by mslattery (Initiate)
on Apr 19, 2002 at 18:50 UTC ( #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? - Answer 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?
[Discipulus]: no, they are my crossword/sudoku like entertainment
Discipulus grins
[marto]: Even with shell command recall I find it less time consuming to do such things in a file.
[marto]: I very seldom use one liners for anything which isn't utterly trivial
[Discipulus]: i'm wise enough to never use my oneliners

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-09-22 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (260 votes). Check out past polls.

    Notices?