in reply to Word Comparison
Interesting how this keeps coming up - it just so happens that I've been working on this class of problems recently.
#!/usr/bin/perl -w use strict; my @words = ("dog good", "food fodder"); TOP: for (@words){ my ($first, $second) = split; for my $ltr (split //, $first){ unless ($second =~ s/$ltr//){ print "'$_' does not match.\n"; next TOP; } } print "'$_' matches.\n"; }
Running it produces the following:
'dog good' matches. 'food fodder' does not match.
It gets much more interesting when the words are made up of cards that can be either one or two letters long... :)
|
|---|