
petreza
Novice
Sep 10, 2010, 6:47 AM
Post #1 of 5
(7515 views)
|
Two strings refuse to match?
|
Can't Post
|
|
Hello, This never prints: if ( $hash1->{'111'} =~ /$hash2->{'222'}/ ){ print "It matches"; } Eventhough when I do this: my @str1 = split ( //, $hash1->{'111'}); my @str2 = split ( //, $hash2->{'222'}); for (my $i=0; $i<=$#str2; $i++){ if ($str1[$i] eq $str2[$i]){ print "character # $i is the same.\n"; }else{ print "!!!!!!!!!!!! character # $i is NOT the same !!!!!!!!!!!!!!!!"; } } all the individual characters match. I have a bunch of these strings inside tha hashes that do not match. Basically, the string inside $hash2->{'xxx'} is a cut-off version of the full string inside $hash1->{'yyy'} yet they do not match. Edit: code editted by shawnhcorey's suggestion below
(This post was edited by petreza on Sep 10, 2010, 12:13 PM)
|