Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re (tilly) 1: Scoped Variables in a Recursive Function.

by tilly (Archbishop)
on Sep 28, 2000 at 17:04 UTC ( #34371=note: print w/ replies, xml ) Need Help??

in reply to Scoped Variables in a Recursive Function.

For my attempt once at explaining the error, take a look at RE (3): BrainPain-Help.

It really is a naming issue.

Functions are given global names from which you can reach them from anywhere, any time. But only one can be available from that name at a time anywhere in the program.

Lexical variables (declared with my) are private names that can only be reached by name from certain blocks of executing code. There may be several copies of a given lexical variable in existence at the same time, but because of how the naming works, they won't be mixed up.

Now Perl is being asked to figure out which copy of a lexical variable will be seen when you call the globally named function and is throwing its hands up in disgust.

Comment on Re (tilly) 1: Scoped Variables in a Recursive Function.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-11-27 09:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (722 votes), past polls