Subject: | Work around Bizarre copy of CODE in list assignment |
Sometimes this line:
@args = @DB::args
produced an error from Perl, "Bizarre copy of CODE in list assignment at /usr/share/perl/5.26/Carp.pm line 229." I understand that's a Perl bug, but it's easy enough to work around in Carp.pm, so at least Carp.pm's user has some chance of figuring out what happened:
local $@;
eval { @args = @DB::args };
if ($@) { @args = ("INTERNAL ERROR: $@") }
... seems to work. So instead of just getting that "Bizarre copy" error (which means nothing to me, and doesn't help me fix my code at all), I get:
[3517] Bad when: -1526400 at «PATH»/Podist line 367.
[3517] at «PATH»/Database.pm line 73.
[3517] Podist::Database::add_article(Podist::Database=HASH(0x563e4bd27758), "feed", 65, "fetch", 21604, "use", 1, "uid", ...) called at «PATH»/Podist line 367
[3517] main::fetch() called at «PATH»/Podist line 176
[3517] main::catch("INTERNAL ERROR: Bizarre copy of CODE in list assignment at /u"...) called at «PATH»/Podist line 125
[3517] main::go() called at «PATH»/Podist line 92
(which got timestamps because since it passed back to my code instead of just die'ing in Carp, it was handed over to Log4perl).
And with the "Bad when" error that my code produced, I can find what actually went wrong before a Perl bug took out Carp.
(This is Carp 1.42 on Perl 5.26.2, Debian testing)