in reply to Count occurrences and rename words in order
Not quite sure what this is needed for, but the following seems to meet your requirements well enough.
#!/usr/bin/perl use warnings; use strict; my $test = 'doc123/print doc456/read doc789/print doc145/print doc123/ +read'; my %count; print join '/', grep {s/^([a-z]+)\s/"$1".(++$count{$1}).' '/ie || $_} split '/', $test;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Count occurrences and rename words in order
by Anonymous Monk on Sep 18, 2002 at 16:41 UTC | |
by Molt (Chaplain) on Sep 19, 2002 at 10:12 UTC |