Yeah, that works. It's unclear what the original poster wanted to do for multiple lines. I assumed that the counts should be cleared. In which case you'd do something like this:
--$ perl -pe '%counts=();s|(/\w+)|$1 . ++$counts{$1}|ge' logfile>counted +logfile
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Re^2: Count occurrences and rename words in order
by davorg
in thread Count occurrences and rename words in order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |