in reply to Matching words based on letter content
use strict; use Data::Dumper; my @words = qw/opt top pot pit tip/; my %count; foreach my $w(@words) { my $key = join '', sort split '', $w; $count{$key}++; } print Dumper \%count;
Output:
$VAR1 = { 'opt' => 3, 'ipt' => 2 };
Update: Added the D::D output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching words based on letter content
by knirirr (Scribe) on Jan 28, 2005 at 15:22 UTC |