in reply to Closures and undefined subs
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->( ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Closures and undefined subs
by ikegami (Patriarch) on Sep 26, 2007 at 14:27 UTC | |
by Anonymous Monk on Sep 26, 2007 at 14:39 UTC | |
by ikegami (Patriarch) on Sep 26, 2007 at 14:46 UTC | |
by ursus (Acolyte) on Sep 28, 2007 at 22:41 UTC | |
|
Re^2: Closures and undefined subs
by Anonymous Monk on Sep 26, 2007 at 14:30 UTC | |
by ikegami (Patriarch) on Sep 26, 2007 at 14:36 UTC |