Exception error in perl code
[email protected] (Rajini Naidu) Wed, 17 Jun 2009 09:42:46 +0530
| Newsgroups | perl.trainers |
|---|---|
| Message-ID | <[email protected]> |
--0016362835eaec971a046c8380ec
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi,
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_path/$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`;
my $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);
}
}
}
When I execute the program 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
----------------------------------------------------------------------------------------------------------------------
-Rajini
--0016362835eaec971a046c8380ec
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<font size=3D"2">
<div>Hi, </div>
<div>=A0</div>
<div>=A0</div>
<div>I have the following code in my program. </div>
<div>=A0</div>
<div>use strict;</div>
<div>use warnings;</div>
<div>use diagnostics;</div>
<div>use Time::Local;</div>
<div>=A0</div>
<div>my @match_list;</div>
<div>my $days1 =3D "";</div>
<div>my $days2 =3D "";</div>
<div>my $day =3D "";</div>
<p>=A0</p>
<p>if ($failtag eq "CompileErr") {</p>
<p>open my $pipe, "-|", "/usr/atria/bin/cleartool", &qu=
ot;desc", "$include_path/$srcfile" or die "could not ru=
n cleartool: $!";</p>
<p>while (<$pipe>) {</p>
<p>next unless /created/;</p>
<p>my @rec =3D split;</p>
<p>push @match_list, substr $rec[1], 0, 9; }</p>
<div>my $NOW=3D`date "+%d-%b-%Y`;</div>
<div>my $t =3D @match_list;</div>
<div>$days1 =3D epoch_days("$NOW");</div>
<div>$days2 =3D epoch_days("$t");</div>
<p>$day =3D $days1 - $days2;</p>
<p>if ($day < 15)</p>
<p>{</p>
<p>$failtag =3D "TestcaseDiff";</p>
<p>}</p>
<p>BEGIN {</p>
<p>my %month_num =3D do {</p>
<p>my $n =3D 0;</p>
<p>map(($_, $n++), qw/jan feb mar apr may jun jul aug sep oct nov dec/);</p=
>
<p>};</p>
<p>sub epoch_days {</p>
<p>my @dmy =3D split /-/, shift;</p>
<p>$dmy[1] =3D $month_num{lc $dmy[1]} || 0;</p>
<p>return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60);</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>When I execute the program I am getting below exception error. </p>
<p>Line 405 in the program points to </p>
<p>"return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60);"</p>
<p>Am I missing anything in code. </p>
<p>------------------------------------------------------------------------=
----------------------------------------</p>
<p>Uncaught exception from user code:</p>
<p>Day '0' out of range 1..31 at /CLO/Tests/CTI/Scripts/drivers/lib=
/regressionDriver.pm line 405</p>
<p>Time::Local::timegm called at /usr/local/lib/perl5/5.8.0/Time/Local.pm l=
ine 120</p>
<p>Time::Local::timelocal(0,0,0,0,0) called at /CLO/Tests/CTI/Scripts/drive=
rs/lib/regressionDriver.pm line 405</p>
<div>----------------------------------------------------------------------=
------------------------------------------------</div>
<div>=A0</div>
<div>-Rajini </div>
<div>=A0</div>
<div>=A0</div></font>
--0016362835eaec971a046c8380ec--