in reply to Nested subroutines and access to variables in an outer scope

thats because your subs inside subs are named. Try unnamed closures and it works fine. The reason is that the vars inside your named functions have a own live.
sub my_func{ my ( $self, $ptr_array, $value ) = @_; my $look_right = sub {... [uses $value and $ptr_array] } my $look_left = sub {... [uses $value and $ptr_array] } return $look_right->() if ( $value == 0 ); return $look_left->() if ( $value == @{ $ptr_array } ); return ( $look_right->() && $look_left->() ); }
Boris

Replies are listed 'Best First'.
Re^2: My Confusion
by PerlingTheUK (Hermit) on Sep 08, 2004 at 13:14 UTC
    That works fine. Thank you.

    PerlingTheUK