in reply to $_, one lexical scope removed

I'm not sure where you are going with this, or if it's a good place to go, but it's possible to do something like what you describe in the second part of your question:

#! perl -slw use strict; sub freaky { my $ref = \@_; return sub { print "$ref->[ 0 ] $_[ 0 ]"; $ref->[ 0 ] = 'joe'; $_[ 0 ] = 'john'; } } my $outerArg = 'bill'; my $freaky = freaky( $outerArg ); my $innerArg = 'fred'; $freaky->( $innerArg ); print "$innerArg $outerArg"; ( $innerArg, $outerArg ) = ( 'kate', 'suzy' ); my $innerArg2 = 'bluto'; $freaky->( $innerArg2 ); print "$innerArg $innerArg2 $outerArg"; __END__ P:\test>374759 bill fred john joe suzy bluto kate john joe

The difference between this and your example is that the anonymous sub can affect the values of the arguments to the outer sub after the fact.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon