in reply to Substring comparisson problem
It's because you're looking for the substring "Hello" with the quotes. Get rid of them and try again:
my $string = "Hello World"; if ($string =~ /Hello/) { print "Basic String contains: Hello\n"; }
Update: You could also put quotes around 'Hello' with any of the following (among other possibilities):
my $string = "\"Hello\" World"; my $string = '"Hello" World'; my $string = q{"Hello" World}; my $string = qq{"Hello" World};
Then your original regex should find the quoted substring "Hello":
if ($string =~ /"Hello"/) { print "Basic String contains: Hello\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Substring comparisson problem
by ChTidio (Initiate) on Nov 27, 2013 at 19:28 UTC | |
by ww (Archbishop) on Nov 27, 2013 at 22:19 UTC | |
by Laurent_R (Canon) on Nov 27, 2013 at 22:49 UTC |