When I execute theelow code I am getting below exception error. Line 405 in the program points to "return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60);" Am I missing anything in code. ---------------------------------------------------------------------------------------------------------------- Uncaught exception from user code: Day '0' out of range 1..31 at /CLO/Tests/CTI/Scripts/drivers/lib/regressionDriver.pm line 405 Time::Local::timegm called at /usr/local/lib/perl5/5.8.0/Time/Local.pm line 120 Time::Local::timelocal(0,0,0,0,0) called at /CLO/Tests/CTI/Scripts/drivers/lib/regressionDriver.pm line 405 ---------------------------------------------
I have the following code in my program. use strict; use warnings; use diagnostics; use Time::Local; my @match_list; my $days1 = ""; my $days2 = ""; my $day = ""; if ($failtag eq "CompileErr") { open my $pipe, "-|", "/usr/atria/bin/cleartool", "desc", "$include_pat +h/$srcfile" or die "could not run cleartool: $!"; while (<$pipe>) { next unless /created/; my @rec = split; push @match_list, substr $rec[1], 0, 9; } my $NOW=`date "+%d-%b-%Y`; m +y $t = @match_list; $days1 = epoch_days("$NOW"); $days2 = epoch_days("$t"); $day = $days1 - $days2; if ($day < 15) { $failtag = "TestcaseDiff"; } BEGIN { my %month_num = do { my $n = 0; map(($_, $n++), qw/jan feb mar apr may jun jul aug sep oct nov dec/); }; sub epoch_days { my @dmy = split /-/, shift; $dmy[1] = $month_num{lc $dmy[1]} || 0; return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60); } } }

In reply to Exception Error in perl code by RajNaidu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.