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

Re: Test::More not working with Perl local special variables

by AnomalousMonk (Abbot)
on Apr 22, 2013 at 19:26 UTC ( #1029959=note: print w/ replies, xml ) Need Help??


in reply to Test::More not working with Perl local special variables

It's a dynamic scoping issue:

>perl -wMstrict -le "my $s = 'foobar'; printf qq{\$& in sub: '%s' \n}, S($s); print qq{\$& post sub: '$&'}; print '$& undefined' unless defined $&; ;; sub S { $_[0] =~ m{ oob }xms; return $&; } " $& in sub: 'oob' Use of uninitialized value $& in concatenation (.) or string at ... $& post sub: '' $& undefined

See the section Variables related to regular expressions in perlvar: "These variables are read-only and dynamically-scoped, unless we note otherwise."


Comment on Re: Test::More not working with Perl local special variables
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2015-07-29 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (267 votes), past polls