sub match_all_letters { my( $match, $in ) = @_; my @letters = split( //, $match ); return @letters == grep { index( $in, $_ ) != -1 } @letters; } __END__ DB<2> x match_all_letters( "the" => "there" ) 0 1 DB<3> x match_all_letters( "zxd" => "there" ) 0 '' DB<4> x match_all_letters( "theq" => "there" ) 0 '' DB<5> x match_all_letters( "abcde" => "gcdabef" ) 0 1