Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Value of $_ inside a regex

by AnomalousMonk (Archbishop)
on Oct 12, 2015 at 07:24 UTC ( [id://1144483]=note: print w/replies, xml ) Need Help??


in reply to Value of $_ inside a regex

Just for support, the following behaves the same under ActiveState 5.8.9 and Strawberry 5.14.4:

c:\@Work\Perl>perl -wMstrict -le "print qq{perl version $]}; ;; my %h = qw(foo ZOT); ;; $_ = 'foo'; ;; print qq{before rx: '$_'}; my $rx = qr{ \A \s* (??{ print qq{in rx: '$_'}; $_; }) }xms; ;; print qq{before match: '$_'}; print 'match' if $h{'foo'} =~ $rx; print qq{after match; '$_'}; " perl version 5.008009 before rx: 'foo' before match: 'foo' in rx: 'ZOT' match after match; 'foo'
And no, I've never encountered this behavior, either (but neither have I looked for it).


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1144483]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found