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 (Chancellor)
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-02-24 20:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (363 votes). Check out past polls.