I finished my script like so:
use strict; use warnings; my %words; my $text = "and him him lad has him done and john has has"; while($text=~/\b(\w+)\b(?=.*\b\1\b)/g){ $words{$1}++; } foreach my $key(keys %words){ my $count = $words{$key} + 1; print "$key: $count\n"; }
Again thank you for the advice.
In reply to Re: regex, find words that occur more than once.
by Anonymous Monk
in thread regex, find words that occur more than once.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |