It's easier to split to do that. When you want to handle uniqueness or duplication, think of using a hash.
my %hash; while (<>) { for (split) { print "dup word '$_' occurs at line $.\n" if $hash{$_}++; } }
You can make that $hash{+lc}++ if you want to ignore case.
After Compline,
Zaxo
In reply to Re: Finding duplicate words in a paragraph
by Zaxo
in thread Finding duplicate words in a paragraph
by perladdict
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |