#!/usr/bin/perl -w use strict; $_ = 'doc123/print doc456/read doc789/print doc145/print doc123/read'; my %counts; s|(/\w+)|$1 . ++$counts{$1}|ge; print;
Seems to give the right output for the sample you gave.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Count occurrences and rename words in order
by davorg
in thread Count occurrences and rename words in order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |