I think your problem is that you've misunderstood the scope of local. As soon as your out subroutine's scope is exited both of in and in2 are restored to their previous contents.
I'm not following exactly why you're trying to do this from your sample code, but I think what you'd want is to store the coderefs in lexically scoped scalars and call things using the arrow syntax rather than mucking about with local and what not.
sub out { my $x = shift; my $in = sub { ... }; my $in2 = sub { ...; my $rs = $in->( $arg ); ... }; return $x + $in_2->( ); }
In reply to Re: Closures and undefined subs
by Fletch
in thread Closures and undefined subs
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |