in reply to Check if a word is included in another
HTH! :)sub is_included { my ($a,$b)=@_; # while ($a) { # UPDATED since buggy while (length $a) { my $c=substr($a,0,1); return 0 if $a =~ s/$c//g > $b =~ s/$c//g ; } return 1; } print is_included(qw/ababa babababab/); # 1 print is_included(qw/babababab ababa/); # 0 print is_included(qw/EASYPEASY PEARLYGATES/); # 0
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check if a word is included in another
by b4swine (Pilgrim) on Apr 18, 2010 at 22:43 UTC | |
by LanX (Saint) on Apr 18, 2010 at 22:50 UTC |