CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: Two strings refuse to match?: Edit Log


Sep 10, 2010, 6:47 AM

Views: 8687
Two strings refuse to match?


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";
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)

Edit Log:
Post edited by petreza (Novice) on Sep 10, 2010, 12:13 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives