Subject: | perl 5.6.1 insn't compiling due to embedded Class::Std::SCR pkg |
The following test is unable to compile under perl 5.6.1:
use strict;
use warnings;
use Class::Std;
I'm getting an infinite recursion in the autoload method trying to find the ID method:
$ perl -d 5-6-1-ex.pl
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
Class::Std::AUTOLOAD(Class/Std.pm:471):
471: my ($invocant) = @_;
100 levels deep in subroutine calls!
DB<1> T
...
$ = Class::Std::AUTOLOAD(' :init_arg<values> ') called from file `Class/Std.pm' line 475
$ = Class::Std::AUTOLOAD(' :init_arg<values> ') called from file `Class/Std.pm' line 91
@ = Class::Std::MODIFY_HASH_ATTRIBUTES('Class::Std::SCR', ref(HASH), 'ATTR( :init_arg<values> )') called from file `/ms/dist/perl5/PROJ/core/5.6.1-1/exec/lib/perl5/attributes.pm' line 46
$ = attributes::import('attributes', 'Class::Std::SCR', ref(HASH), 'ATTR( :init_arg<values> )') called from file `Class/Std.pm' line 524
$ = Class::Std::SCR::BEGIN() called from file `/ms/dist/perl5/PROJ/core/5.6.1-1/exec/lib/perl5/attributes.pm' line 524
$ = eval {...} called from file `/ms/dist/perl5/PROJ/core/5.6.1-1/exec/lib/perl5/attributes.pm' line 524
$ = require 'Class/Std.pm' called from file `5-6-1-ex.pl' line 21
$ = main::BEGIN() called from file `/ms/dist/perl5/PROJ/core/5.6.1-1/exec/lib/perl5/attributes.pm' line 524
$ = eval {...} called from file `/ms/dist/perl5/PROJ/core/5.6.1-1/exec/lib/perl5/attributes.pm' line 524
DB<1>
(The line numbers may not exactly match with the disted code because I had inserted some debugging statements. Line 91 is a call to _extract_default)
After a bit of debugging, I found that in perl 5.6 the code which defines *ID and the *_extract_ subroutines was not getting executed prior to the first time the autoloader was called.
This seems to be either because the CHECK block is getting executed or the Class::Std::SCR code is getting executed prior to the code in Class::Std being executed.
Either way, a solution is to move the Class::Std::SCR code to a separate file, put a 'require Class::Std::SCR' or 'eval "use Class::Std::SCR";' at the top of the CHECK block.
This does not happen in perl 5.8.4.