could someone please explain this behaviour to me as it is unexpected for me:
In the first case I compile a regex immediately, in the second I define a string and only in the line where I match it get's compiled.my $regex1 = qr/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my $regex2 = qq/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my ($match1) = q|"hubba \"bubba\""| =~ $regex1; my ($match2) = q|"hubba \"bubba\""| =~ /$regex2/; print "$match1\n$match2\n"; __END__ output: hubba \"bubba\" hubba \
I would have expected that the result would be the same - but it isn't...
Why?
Many thanks!
In reply to regex compilation by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |