Hi,

I was under the impression that regex modifier '/x' ignores the white
space. So in following script both the if-else blocks should print
"Match" since the strings differ only in white space and '/x' should
ignore the white space.

But looks like my understanding of '/x' is wrong. Could someone please
correct me and explain the below behavior.

#!/usr/bin/perl
use strict;
use warnings;
my $str = "Hello World";
my $str2 = "Hello World";
my $str3 = "Hello    World";

if($str =~/$str2/x){
    print "Match\n";
} else {
    print "No Match\n";
}

if($str =~/$str3/x){
    print "Match\n";
} else {
    print "No Match\n";
}


Cheers,
Parag

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to