in reply to Re: Check if a word is included in another
in thread Check if a word is included in another
Interesting thought, just need a a little bit tweak:
use warnings; use strict; print check("YLPP", "PEARLYGATES"), "\n"; print check("YLP", "PEARLYGATES"), "\n"; print check("EASYPEASY", "PEARLYGATES"), "\n"; sub check { my ($word, $target) = @_; foreach my $letter (split //, $word) { return "not ok" if ($target =~ s/$letter// == 0); } return "ok"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Check if a word is included in another
by b4swine (Pilgrim) on Apr 18, 2010 at 22:20 UTC | |
by PeterPeiGuo (Hermit) on Apr 18, 2010 at 23:07 UTC | |
by b4swine (Pilgrim) on Apr 18, 2010 at 23:18 UTC |