sub is_anagram { my ($word, $test) = @_; foreach my $letter (split(//, $word)) { return unless $test =~ s/$letter//; } return if $test; # leftovers return 1; }
A regex isn't the most efficient method for approaching this (and this example is probably the least efficient of all), but it's easy to understand. Many of the optimizations people made in Difference Of Two Strings can probably be applied here.
In reply to Re: Anagram matching
by Fastolfe
in thread Anagram matching
by JungleBoy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |