I am trying to split a string on markers that I don't want to hard-code. My patterns aren't behaving - here's a simple stub of what is throwing me.
use strict; my $patt1 = '!!'; my $patt2 = '++'; my $string = 'hello!!there++everyone!!in the web'; if ( $string =~ m{$patt1} ) { print "Matches patt1\n"; } if ( $string =~ m{\Q $patt2 \E}x ) { print "Matches patt2 with /x\n"; } if ( $string =~ m{\Q$patt2\E} ) { print "Matches patt2\n"; }
I would have thought this would have matched all 3 times but the /x modifier doesn't match it. Does the \Q\E make the spaces significant?
Can someone see why?
Thanks!
In reply to /x modifier with \Q and \E by wardy3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |