Click here to get back home

Use of uninitialized value in numeric lt (<) at /Date/Manip.pm

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Use of uninitialized value in numeric lt (<) at /Date/Manip.pm John Nagle 09-16-2008
Get Chitika Premium
Posted by John Nagle on September 16, 2008, 12:58 pm
Please log in for more thread options


This has me puzzled. This code worked on another server, but it's
failing on perl v5.8.8, with Date::Manip loaded from CPAN today.

Warning:
Use of uninitialized value in numeric lt (<) at /home/downside/lib/Date/Manip.pm
line 3327.

at dailyupdate.pl line 13
main::__ANON__('Use of uninitialized value in numeric lt (<) at
/home/downsid...') called at

/home/downside/lib/Date/Manip.pm line 3327
Date::Manip::Date_SecsSince1970GMT(09, 16, 2008, 00, 21, 22) called at
/home/downside/lib/Date/Manip.pm line 1905
Date::Manip::UnixDate('today', '%Y-%m-%d') called at
TICKER/SYMBOLS/updatesymbols.pm line 122
TICKER::SYMBOLS::updatesymbols::getdate() called at
TICKER/SYMBOLS/updatesymbols.pm line 439
TICKER::SYMBOLS::updatesymbols::updatesymbol('DBI::db=HASH(0x87fcc34)',

'TICKER::SYMBOLS::symbol=HASH(0x8a43540)') called at
TICKER/SYMBOLS/updatesymbols.pm line 565

TICKER::SYMBOLS::updatesymbols::updatesymbols('DBI::db=HASH(0x87fcc34)', 1, 0,
-1) called at

dailyupdate.pl line 149
EDGAR::updatesymbols('DBI::db=HASH(0x87fcc34)', 1, 0, -1) called at
dailyupdate.pl line 180
EDGAR::dailyupdate() called at dailyupdate.pl line 193


The code that's failing is simply

sub getdate()
{        my $err;                                ## today
        &Date::Manip::Date_Init('TZ=EST5EDT');                
        my $today = Date::Manip::UnixDate('today','%Y-%m-%d'); ## today's date
        ####print "Today is ",$today,"\n";                ## ***TEMP***
        return($today);
}

That's right; Date::Manip is failing for "today".

The line in Date::Manip that is failing is

my($tz)=$Cnf;
$tz=$Cnf if (! $tz);
$tz=$Zone if ($tz !~ /^[+-]\d$/);

my($tzs)=1;
$tzs=-1 if ($tz<0); ### ERROR OCCURS HERE


So Date::Manip is assuming that $Cnf has been initialized with elements "ConvTZ"
or "TZ". Those are initialized in Date_Init, so that should have been
taken care of.

It's only failing in my large program. If I just extract "getdate()" above
and run it standalone, there's no error. So there's something about the
global environment that affects this.

This seems to be a known, but un-understood problem. If you search Google for
"Use of uninitialized value date manip" there are about 2400 hits.
This error has been reported with MythTV
("http://www.lemis.com/grog/videorecorder/mythsetup-sep-2006.html")
and grepmail ("http://www.cpan.org/modules/by-module/Mail/grepmail-4.51.readme").

                                John Nagle






Posted by sisyphus on September 16, 2008, 11:38 pm
Please log in for more thread options


.
.
> The line in Date::Manip that is failing is
>
> =A0 =A0my($tz)=3D$Cnf;
> =A0 =A0$tz=3D$Cnf =A0if (! $tz);
> =A0 =A0$tz=3D$Zone =A0if ($tz !~ /^[+-]\d$/);
>
> =A0 =A0my($tzs)=3D1;
> =A0 =A0$tzs=3D-1 if ($tz<0); ### ERROR OCCURS HERE

It's just a warning - not an error in itself. But if it's leading to
incorrect results, then there's probably something not right :-)

>
> So Date::Manip is assuming that $Cnf has been initialized with elements "=
ConvTZ"
> or "TZ".

I think $tz must be *initialized* by the time

$tz=3D$Zone if ($tz !~ /^[+-]\d$/);

gets run. If it were not initialized at that stage you'd get a warning
along the lines of "Use of uninitialized value $tz in pattern match
(m//) at Manip.pm line 3324. That being so, it must be the '$tz =3D
$Zone' that's assigning undef to $tz - since there's
no other way that an initialized $tz could become uninitialized (that
I can think of, anyway).

Probably wouldn't hurt to hack in some print() statements just to see
what $tz contains at various stages - and also to check what
$Zone contains. I don't know much about Date::Manip,
but my hunch is that it's the contents of $Zone that's
causing the problem.

Cheers,
Rob


Similar ThreadsPosted
Image magic problem Use of uninitialized value in numeric gt (>) March 20, 2006, 7:12 pm
XML::Generator::DBI - use of uninitialized value on line 180 and 187 September 12, 2004, 8:00 pm
GD::Graph isn't numeric etc. January 26, 2005, 7:43 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap