devrooms
devrooms

Reputation: 3149

Perl issue with DateTime::Format::ISO8601 tracked to issue with Params::Validate?

Hope someone can shed some light on this...

I, and many other developers in the team have a large scale in house perl app running. Despite this all working fine, across everyones laptops (linux and mac's), I can't for the life of me get this run on my big PC at home.

I've installed all the dependencies via cpan, but i'm getting the following in the apache error logs when visiting the site:

The 'regex' parameter ("(?x-ism:^ (\d{4}) (\d\d) (\d\d) $)") to DateTime::Format::Builder::Parser::create_single_parser was an 'unknown', which is not one of the allowed types: scalarref
 at /usr/local/lib/perl/5.12.4/Params/ValidatePP.pm line 651
    Params::Validate::__ANON__('The \'regex\' parameter ("(?x-ism:^ (\d{4}) (\d\d) (\d\d) $)"...') called at /usr/local/lib/perl/5.12.4/Params/ValidatePP.pm line 491
    Params::Validate::_validate_one_param('Regexp=REGEXP(0x7f8a3aad06e8)', 'HASH(0x7f8a3aaea840)', 'HASH(0x7f8a3aa75aa8)', 'The \'regex\' parameter ("(?x-ism:^ (\d{4}) (\d\d) (\d\d) $)")') called at /usr/local/lib/perl/5.12.4/Params/ValidatePP.pm line 353
    Params::Validate::validate('ARRAY(0x7f8a3aa33808)', 'HASH(0x7f8a3aa32db8)') called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder/Parser.pm line 312
    DateTime::Format::Builder::Parser::create_single_parser(undef, 'params', 'ARRAY(0x7f8a3aad0640)', 'length', 8, 'regex', 'Regexp=REGEXP(0x7f8a3aad06e8)') called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder/Parser.pm line 504
    DateTime::Format::Builder::Parser::sort_parsers('DateTime::Format::Builder::Parser', 'HASH(0x7f8a3aa4e2b8)', 'ARRAY(0x7f8a3aa3f148)') called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder/Parser.pm line 398
    DateTime::Format::Builder::Parser::create_multiple_parsers('DateTime::Format::Builder::Parser', 'HASH(0x7f8a3aa4e2b8)', 'HASH(0x7f8a3aad06b8)', 'HASH(0x7f8a3aad0808)', 'HASH(0x7f8a3aad0910)', 'HASH(0x7f8a3aad0a00)', 'HASH(0x7f8a3aad0b08)', 'HASH(0x7f8a3aad0cb8)', 'HASH(0x7f8a3aad0e50)', ...) called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder/Parser.pm line 603
    DateTime::Format::Builder::Parser::create_parser('DateTime::Format::Builder::Parser', 'ARRAY(0x7f8a3a72fc88)', 'HASH(0x7f8a3aad06b8)', 'HASH(0x7f8a3aad0808)', 'HASH(0x7f8a3aad0910)', 'HASH(0x7f8a3aad0a00)', 'HASH(0x7f8a3aad0b08)', 'HASH(0x7f8a3aad0cb8)', 'HASH(0x7f8a3aad0e50)', ...) called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder.pm line 158
    DateTime::Format::Builder::create_parser('DateTime::Format::Builder', 'ARRAY(0x7f8a3aae5450)') called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder.pm line 177
    DateTime::Format::Builder::create_end_parser('DateTime::Format::Builder', 'ARRAY(0x7f8a3aae5450)') called at /usr/local/share/perl/5.12.4/DateTime/Format/Builder.pm line 106
    DateTime::Format::Builder::create_class(undef, 'parsers', 'HASH(0x7f8a3aae8f18)') called at /usr/local/share/perl/5.12.4/DateTime/Format/ISO8601.pm line 175

I've stuck some noddy print STDERR's directly in the ValidatePP.pm so if you are looking at the line numbers and they are slightly out, but basically in ValidatePP.pm it is getting to the following code block in sub _get_type:

 # I really hope this never happens.
 return UNKNOWN;

If it helps, running a perl -v returns the following version on this PC

This is perl 5, version 12, subversion 4 (v5.12.4) built for x86_64-linux-gnu-thread-multi

Anybody?

UPDATE:

If it helps, the subroutine _get_type is basically deciding (using UNIVERSAL::isa) that regex: !!perl/regexp (?x-ism:^ (\d{4}) (\d\d) (\d\d) $) is not one if the following:

my %isas = (
        'ARRAY'  => ARRAYREF,
        'HASH'   => HASHREF,
        'CODE'   => CODEREF,
        'GLOB'   => GLOBREF,
        'SCALAR' => SCALARREF,
    );

Upvotes: 2

Views: 602

Answers (1)

yibe
yibe

Reputation: 4109

First of all, are you using the latest version of Params::Validate (and all the other modules)? According to the changelog there were some bugs in P::V 1.01:

1.02 2012-02-06

  • The previous release never loaded the XS implementation, even if it had been compiled.

  • With newer versions of Perl, the pure Perl implementation treated regexp objects differently than the XS implementation. They should be treated as belonging to the SCALARREF type for backwards compatibility.

  • These two bugs combined managed to break the test suites of a number of modules on CPAN. This release should fix them.

Upvotes: 1

Related Questions