in reply to DateTime->now problem

Do you get the error when you run 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 }, }; validate( @{[ 'epoch', 1301690690 ]}, $spec );

Does it say "PP" or "XS"?

Update: Added PP/XS bit.

Replies are listed 'Best First'.
Re^2: DateTime->now problem
by Grimey (Novice) on Apr 01, 2011 at 21:35 UTC

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

      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

      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

Re^2: DateTime->now problem
by Grimey (Novice) on Apr 01, 2011 at 21:29 UTC

    Yes

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

      You're too fast! I added a check to see which of P::V's backends you use.