In 2002/2003 I wrote Exporter-VA, or Exporter with Versioning and Aliasing, with the intention of then updating classic modules to be more OO, allowing the old and new API to co-exist in one release.

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:

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 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.

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.


In reply to My AUTOLOAD doesn't work in newer Perls. How to fix? by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.