Ovid has asked for the wisdom of the Perl Monks concerning the following question:
I have some code which relies heavily on the fact that I can localize variables in recursive functions. However, sometimes I need to examine the top of the local stack:
#!/usr/bin/perl -l use strict; use warnings; our $x = 3; foo(7); sub foo { local $x = shift; print $x; # is there any way to get the "3" value? }
The obvious solution is for me to cache the top-level values of the variables in question and that's probably what I will do, but I was wondering if there is any way to examine the stack created by local? I'd prefer to do this without C, but if I must ...
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Examing local's stack
by chromatic (Archbishop) on Mar 21, 2006 at 19:00 UTC | |
|
Re: Examing local's stack
by codeacrobat (Chaplain) on Mar 21, 2006 at 19:21 UTC | |
by polettix (Vicar) on Mar 22, 2006 at 10:36 UTC | |
|
Re: Examing local's stack
by Anonymous Monk on Mar 21, 2006 at 20:34 UTC | |
by adrianh (Chancellor) on Mar 22, 2006 at 09:53 UTC | |
|
Re: Examing local's stack
by Elian (Parson) on Mar 24, 2006 at 02:26 UTC | |
by Ovid (Cardinal) on Mar 24, 2006 at 07:02 UTC | |
by Elian (Parson) on Mar 24, 2006 at 16:02 UTC |