in reply to Re^2: Stupid question about strings...
in thread Stupid question about strings...
Your test is wrong for the following reason: if you want to try to put string1 on the right side, then it is string1 that should be a quotemetaed regex or have the pipes escaped:$ perl -E 'my $str1 = qq(one two three); my $str2 = qq(two); if ($str +2 =~ m/$str1/) { say "foo";}' $ perl -E 'my $str1 = qq(one two three); my $str2 = qq(two); if ($str +1 =~ m/$str2/) { say "foo";}' foo
$ perl -E 'my $str1 = qr(\|L\|D\|); my $str2 = qq(\|L\|); if ($str2 = +~ m/$str1/) { say "foo";}' $ perl -E 'my $str1 = qq(\|L\|D\|); my $str2 = qr(\|L\|); if ($str1 = +~ m/$str2/) { say "foo";}' foo $ perl -E 'my $str1 = qq(|L|D|); my $str2 = qq(|L|); if ($str1 =~ m/\ +Q$str2/) { say "foo";}' foo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Stupid question about strings...
by ww (Archbishop) on Jul 14, 2014 at 16:54 UTC | |
by AnomalousMonk (Archbishop) on Jul 14, 2014 at 23:48 UTC | |
by Laurent_R (Canon) on Jul 15, 2014 at 08:26 UTC | |
by ww (Archbishop) on Jul 15, 2014 at 12:18 UTC | |
by Laurent_R (Canon) on Jul 15, 2014 at 17:42 UTC |