http://www.perlmonks.org?node_id=11084


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.