$ perl -pe '%counts=();s|(/\w+)|$1 . ++$counts{$1}|ge' logfile>countedlogfile