Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exception error in perl code

4 views
Skip to first unread message

Rajini Naidu

unread,
Jun 17, 2009, 12:12:46 AM6/17/09
to perl-t...@perl.org
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
 
 

Steven Lembark

unread,
Jun 17, 2009, 7:20:48 AM6/17/09
to perl-t...@perl.org
On Wed, 17 Jun 2009 09:42:46 +0530
Rajini Naidu <rajin...@gmail.com> wrote:

> Hi,
>
>
> I have the following code in my program.

You would be better off sending this to a list about
Perl troubleshooting. This list is for teachers.


--
Steven Lembark 85-09 90th St.
Workhorse Computing Woodhaven, NY, 11421
lem...@wrkhors.com +1 888 359 3508

Jacinta Richardson

unread,
Jun 20, 2009, 5:11:04 AM6/20/09
to Rajini Naidu, perl-t...@perl.org
Rajini Naidu wrote:

> I have the following code in my program.

As I answered you back in May:

"The purpose of this mailing list isn't to provide assistance to Perl
students, but rather so that Perl trainers can share ideas about their
training courses. ...

You may also find the perlmonks web forum (http://perlmonks.org/) to be
a helpful place to seek further assistance."

PerlMonks is also a very good resource because of the sheer number of
fantastic tutorials available there. If you need to learn anything (for
example CGI programming) there's a lot of great starting points there.

Another venue you may find of value is your local Perl Mongers group.
I'm not sure where you're based, so perhaps you don't have one in your
city, but usually Perl Mongers groups are open for non-locals to join
to. (I'm certainly a member of quite a few!) To find out what Perl
Monger groups are near you check out the map and geographical categories
at: http://www.pm.org/


Regarding the problem you posted, you may want to look at Perl's time()
and localtime() functions, as a quick glance seems that you're calling
out to the system's date command and then trying to translate that.

You might also want to pay attention to the error you're getting:

> Day '0' out of range 1..31 at
> /CLO/Tests/CTI/Scripts/drivers/lib/regressionDriver.pm line 405

for some reason, you're passing in a day value of 0.

J

0 new messages