On 6/16/09 Tue  Jun 16, 2009  9:14 PM, "Rajini Naidu" <rajinid...@gmail.com>
scribbled:

> 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;

$t now contains the number of elements of @match_list. Are you trying to
assign the first element ($match_list[0]) or the last element
($match_list[$#match_list)?

> $days1 = epoch_days("$NOW");
> $days2 = epoch_days("$t");

Since $t does not contain a valid date, the parsing done in epoch_days()
will likely fail.

> 
> $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



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to