Better to meta-quote $s2 to avoid strange effects from regex metacharacters in it ( //p regex modifier available with 5.10+):
>perl -wMstrict -le "my $s1 = 'foo not *UN*known but bar is'; my $s2 = '*UN*known'; ;; die qq{'$s2' not in '$s1'} unless $s1 =~ m{ \Q$s2\E }xmsp; print qq{all after: '${^POSTMATCH}'}; " all after: ' but bar is'
In reply to Re^2: Perl Substr
by AnomalousMonk
in thread Perl Substr
by lddzjwwy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |