John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
I never got around to doing any of that.
But, Exporter::VA doesn't work on newer versions of Perl. I get an error, “(Can't goto subroutine from an eval-block at /var/content/dev/Exporter-VA-1.3.0.1/blib/lib/Exporter/VA.pm line 558.”
The code in question is:
The AUTOLOAD calls this to create and install the thunk for the named function, which checks the caller and redirects to the old version or the new version as the caller declared it wanted. This allows functions to change in incompatible ways while still supporting old code in the same programs.sub autoload_symbol { my ($self, $symbol, @extra)= @_; my %memory; my $home= $self->{'..home'}; my $thunk= sub { my $retval= eval { my $caller= _calling_client(); # so I don't have to figure it +out multiple times my $f= $memory{$caller}; unless (defined $f) { $f= $memory{$caller}= $self->resolve ($caller, $home->VERSIO +N(undef,$caller), '&'.$symbol, [@extra]); } goto &$f; ######### Error line is Here <<<<<<<<< }; if ($@) { carp "(Exporter::VA) Cannot redirect to versioned function ($@) +"; } return $retval; }; no strict 'refs'; *{"${home}::$symbol"}= $thunk; }
The generated thunk jumps to the actual target using the redirection form of goto. I guess it's complaining that I'm catching exceptions from that process and, at the very least, giving a more meaningful error message, and Carps rather than just plain dieing.
If I change the eval to a do (and remove the following if "catch" statement) it passes all tests. So how do you trap errors now? Having stuff that is not allowed in a try block just isn't nice.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: My AUTOLOAD doesn't work in newer Perls. How to fix?
by JavaFan (Canon) on May 17, 2011 at 09:38 UTC | |
by John M. Dlugosz (Monsignor) on May 17, 2011 at 09:46 UTC | |
by JavaFan (Canon) on May 17, 2011 at 12:16 UTC | |
by moritz (Cardinal) on May 17, 2011 at 13:50 UTC | |
by ikegami (Patriarch) on May 17, 2011 at 17:35 UTC | |
Re: My AUTOLOAD doesn't work in newer Perls. How to fix?
by jettero (Monsignor) on May 17, 2011 at 09:36 UTC | |
by John M. Dlugosz (Monsignor) on May 17, 2011 at 09:39 UTC | |
by moritz (Cardinal) on May 17, 2011 at 13:49 UTC |