in reply to Re: DateTime->now problem
in thread DateTime->now problem

XS 'regex' validation parameter for 'N/A must be a string or qr// regex at monktest.pl line 20

Replies are listed 'Best First'.
Re^3: DateTime->now problem
by ikegami (Patriarch) on Apr 01, 2011 at 21:47 UTC

    What's the output of the following?

    use strict; use warnings; use Params::Validate qw( validate validate_pos UNDEF SCALAR BOOLEAN HASHREF OBJECT ); print($INC{'Params/ValidateXS.pm'} ?'XS':'PP',"\n"); my $spec = { epoch => { regex => qr/^-?(?:\d+(?:\.\d*)?|\.\d+)$/ }, locale => { type => SCALAR | OBJECT, optional => 1 }, language => { type => SCALAR | OBJECT, optional => 1 }, time_zone => { type => SCALAR | OBJECT, optional => 1 }, formatter => { type => SCALAR | OBJECT, can => 'format_datetime', optional => 1 }, }; use Devel::Peek; Dump($spec->{epoch}{regex}); my $x = $spec->{epoch}{regex}; Dump($spec->{epoch}{regex}); validate( @{[ 'epoch', 1301690690 ]}, $spec );

      XS SV = IV(0xa26f58) at 0xa26f60 REFCNT = 1 FLAGS = (ROK) RV = 0xa26f48 SV = REGEXP(0xa67418) at 0xa26f48 REFCNT = 1 FLAGS = (OBJECT,POK,FAKE,pPOK) IV = 0 PV = 0xa75e90 "(?-xism:^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$)" CUR = 36 LEN = 0 STASH = 0xa0b8f0 "Regexp" SV = IV(0xa26f58) at 0xa26f60 REFCNT = 1 FLAGS = (ROK) RV = 0xa26f48 SV = REGEXP(0xa67418) at 0xa26f48 REFCNT = 2 FLAGS = (OBJECT,POK,FAKE,pPOK) IV = 0 PV = 0xa75e90 "(?-xism:^-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)$)" CUR = 36 LEN = 0 STASH = 0xa0b8f0 "Regexp" 'regex' validation parameter for 'N/A must be a string or qr// regex at monktest.pl line 25

        Identical to me. I don't know how you could be getting that error. The code in question is
        if ((temp = hv_fetch(spec, "regex", 5, 0))) { dSP; IV has_regex = 0; IV ok; SvGETMAGIC(*temp); if (SvPOK(*temp)) { has_regex = 1; } else if (SvROK(*temp)) { SV* svp; svp = (SV*)SvRV(*temp); #if PERL_VERSION <= 10 if (SvMAGICAL(svp) && mg_find(svp, PERL_MAGIC_qr)) { has_regex = 1; } #else if (SvTYPE(svp) == SVt_REGEXP) { has_regex = 1; } #endif } if (!has_regex) { SV* buffer; buffer = sv_2mortal(newSVpv("'regex' validation parameter +for '", 0)); sv_catsv(buffer, get_called(options)); sv_catpv(buffer, " must be a string or qr// regex\n"); FAIL(buffer, options); }

        You can probably get around the problem by using the pure Perl backend. You can do that by setting environment variable PV_TEST_PERL to something true.

        PV_TEST_PERL=1 perl script.pl
        or
        BEGIN { $ENV{PV_TEST_PERL} = 1; }
Re^3: DateTime->now problem
by ikegami (Patriarch) on Apr 01, 2011 at 21:39 UTC
    Digging into the XS. In the meantime, you might want to try reinstalling Params::Validate.

      Tried with the same result, thanks for all the the help so far though