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; }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Re: Re: Count occurrences and rename words in order
by davorg
in thread Count occurrences and rename words in order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |