Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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?
[atcroft]: Sounds like it will make display modifications a little easier when you are done, at least.
[Lady_Aleena]: Well, some of the data returned is taylored for the printing of certain elements.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-05-29 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?