in reply to Examing local's stack

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?

Create your own stack without bothering with local()? It doesn't sound like it's doing what you want it to do, so, performance issues aside, why bother with it?

{ # start of block of variables private to function foo() my @stack; sub foo { my ($var) = shift; push(@stack, $x); $x=$var; # code involving foo() and $x goes here... $x=pop(@stack); } # end foo } # end block of variables private to function foo()

Just a thought...

--
Ytrew

Replies are listed 'Best First'.
Re^2: Examing local's stack
by adrianh (Chancellor) on Mar 22, 2006 at 09:53 UTC
    Create your own stack without bothering with local()?

    Or localise your stack.

    our @x = 3; foo(7); sub foo { local @x = ( shift, @x ); print $x[0], "\n"; }

    Not the most efficient thing in the world though... I miss languages where I can apply expressions to dynamic scope entry/exit :-)