Something like this?
#! perl -sw my $data ='doc123/print doc456/read doc789/print doc145/print doc123/r +ead '; my @events = qw(print read); for (@events) { my $count = 1; $data =~ s/($_)/$1.$count++/ge; } print $data; __END__ # Output C:\test>198864 doc123/print1 doc456/read1 doc789/print2 doc145/print3 doc123/read2 C:\test>
In reply to Re: Count occurrences and rename words in order
by BrowserUk
in thread Count occurrences and rename words in order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |