Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 wandering the Monastery: (6)
As of 2014-07-22 08:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (106 votes), past polls