in reply to time validation

Date::Calc provides check_date and check_time try those.

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re^2: time validation
by wol (Hermit) on May 19, 2009 at 11:16 UTC
    Those functions take separate parameters for year, month, day, etc. You'd need some glue code to parse the string of digits into those parts. Eg:
    if ($stringToTest =~ m/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/ & +& check_date($1, $2, $3) && check_time($4, $5, $6) ) { print "It's OK\n"; }
    I suspect there's a way to simplify that regular expression - too much repetition!

    --
    use JAPH;
    print JAPH::asString();

      >perl -wMstrict -le "my $s = '20090527051000'; my @matches = $s =~ m{ \A \d{4} | \d{2} }xmsg; print qq{@matches}; " 2009 05 27 05 10 00
        even if we give $s = '20090230051000'; o/p is 2009 02 30 05 10 00 I am looking for validation of dates. As you can see its displaying 30th feb, which is not right.