Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

Re^3: Strange behavior: passing $1 to AUTOLOAD

by Elian (Parson)
on Sep 22, 2004 at 22:50 UTC ( #393072=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Strange behavior: passing $1 to AUTOLOAD
in thread Strange behavior: passing $1 to AUTOLOAD

The general rule is never, ever pass in $1 and its friends, as they're terribly ephemeral. Make copies and pass them in instead.


Comment on Re^3: Strange behavior: passing $1 to AUTOLOAD
Re^4: Strange behavior: passing $1 to AUTOLOAD
by ysth (Canon) on Sep 23, 2004 at 03:52 UTC
    Make copies and pass them in instead.
    This is as easy as just passing "$1" instead of $1.
Re^4: Strange behavior: passing $1 to AUTOLOAD
by nobull (Friar) on Sep 23, 2004 at 06:53 UTC
    The general rule is never, ever pass in $1 and its friends, as they're terribly ephemeral. Make copies and pass them in instead.
    That's a good general rule but I'd still go for belt and braces.

    If the API of a function doesn't say it treats its arguments as lvalues then it is good practice to make copies of the elements from @_. If you need to do any regex processing before you unpack @_ then wrap it in a block.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://393072]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls