Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 browsing the Monastery: (9)
As of 2014-12-22 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (126 votes), past polls