in reply to Re: Re: Re: Defining a subroutine in another package
in thread Defining a subroutine in another package

I have had problems with it under 5.005: it did not like the sub, although it looked OK and was compiled without a hitch in 5.6.0 and above. So yes the construct works but it looks to me like what you put in the sub can be a problem.

Here is what caused the problem:

my( $text_method, $nav); # actually defined and initialized earlier { no strict 'refs'; my ${text_method}= sub { my $elt=shift; my $dest= $elt->$nav( @_) or return ''; return $dest->text; } }