in reply to stuck on newb problem

my $str1 = "olleh"; my $str2 = "elloh"; if ( $str1 =~ /\A[$str2]+\z/ ) { print "$str1 and $str2 contain the same characters.\n"; }

Replies are listed 'Best First'.
Re^2: stuck on newb problem
by GrandFather (Saint) on Apr 28, 2012 at 05:26 UTC

    for the definition of "same characters" where you mean the same set of unique characters. However the OP probably wouldn't consider:

    my $str1 = "olleh"; my $str2 = "eelooooh";

    to "contain the same characters", but they pass the test.

    True laziness is hard work
Re^2: stuck on newb problem
by mbethke (Hermit) on Apr 28, 2012 at 06:18 UTC

    Fast but loose! Try with $str1 = "e" :)

    Edit: keeping the tab open too long obsoletes many a post ...