Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Side effect of passing matched values by reference

by LanX (Canon)
on Feb 21, 2013 at 17:47 UTC ( #1019992=note: print w/ replies, xml ) Need Help??


in reply to Side effect of passing matched values by reference

Please ...

$1 is a global variable which should only be carefully used in local context.

But your match within the sub changes this global variable and your alias in $_[0] reflects this.

And after leaving the sub the implicit localization restores the old value of $1...

Better stop messing with perl internals or just pass a copy of $1 or follow chorobas suggestion.

Cheers Rolf


Comment on Re: Side effect of passing matched values by reference

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019992]
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: (16)
As of 2015-07-28 14:34 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 (256 votes), past polls