in reply to Re: Re: Count occurrences and rename words in order
in thread Count occurrences and rename words in order

You just need to reset %count to be empty before processing each line.

while (<INPUT>) { my %counts; s|(/\w+)|$1 . ++$counts{$1}|ge; print OUTPUT; }
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg