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

It works for me on 5.004_5 and (I presume) even earlier, though you'll have to disable strict 'refs'.

It's just a symbolic access to a typeglob, nothing special. :)

  • Comment on Re: Re: Re: Defining a subroutine in another package

Replies are listed 'Best First'.
Re: Re: Re: Re: Defining a subroutine in another package
by mirod (Canon) on Jan 31, 2002 at 09:50 UTC

    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; } }