in reply to Inner Subroutines, mod_perl, and Segfaults

If you really want a "local" subroutine, you write:

{ my $cmpval; BEGIN { $cmpval= sub { my ($val1, $val2) = @_; if (ref($val1) eq 'Node') { $val1 = $$val1{node_id}; }; if (ref($val2) eq 'Node') { $val2 = $$val2{node_id}; } $val1 eq $val2; }; } sub getWorkspace { # ... $match = 0 unless &$cmpval($$N{$_}, $$WHERE{$_}); # ... } }
FYI.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
(tye)Re9: Inner Subroutines, mod_perl, and Segfaults
by tye (Sage) on Jan 27, 2001 at 00:07 UTC

    ...and, of course, this won't work at all well under mod_perl. ):

            - tye (but my friends call me "Tye")

      ...but, of course (5 years later), it is easy to make this work well under mod_perl:

      BEGIN { my $cmpval= sub { my( $val1, $val2 )= @_; if( ref($val1) eq 'Node' ) { $val1= $val1->{node_id}; } if( ref($val2) eq 'Node' ) { $val2= $val2->{node_id}; } return $val1 eq $val2; }; sub getWorkspace { # ... $match= 0 if ! $cmpval->( $N->{$_}, $WHERE->{$_} ); # ... } }

      - tye