Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Scope of lexical variables in the main script

by Anonymous Monk
on Apr 20, 2012 at 06:07 UTC ( [id://966092]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Scope of lexical variables in the main script
in thread Scope of lexical variables in the main script

$tricky stays alive as long as there is a reference to it, all the way up until perl exits.

Here is another circular reference, a self-referential variable, it lives even after its inaccessible

{ my $TRICKIEST = "LEAK THAT LIVES FOREVER"; $TRICKIEST = \$TRICKIEST; } ## its alive here, though there is no way to get to it

Well, you could use trickery like PadWalker to get at $TRICKIEST, but that is cheating :)

See Tutorials: Variable Scoping in Perl: the basics, Coping with Scoping

Mini-Tutorial: Perl's Memory Management

Memory leaks and circular references, Circular references and Garbage collection., make perl release memory

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found