Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: my vs. local subtlety

by ysth (Canon)
on Jul 03, 2006 at 22:24 UTC ( [id://559059]=note: print w/replies, xml ) Need Help??


in reply to Re: my vs. local subtlety
in thread my vs. local subtlety

I thought it might be helpful to others to note the subtle "gotcha" between defining variables with "my" and with "local" when using a construct such as $$ctm.

Or a construct such as $#$arrnm or $$arrnm[$$ctm]. That is to say, your @out_a, etc. arrays also cannot be lexical (my) variables.

The distinction isn't between my and local, it's between lexical and package variables. Symbolic refs (which look up a variable by an expression giving it's name) always find package variables, not lexical ones.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found