S, Rajini (STSD) wrote: > From: Owen [mailto:rc...@pcug.org.au] >> S, Rajini (STSD) wrote: >>> >>> When I included the below code in my script, I am getting below >>> errors. >>> >>> Use of uninitialized value in integer ge (>=) at >>> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73. >>> Use of uninitialized value in integer lt (<) at >>> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73. >>> Use of uninitialized value in integer ge (>=) at >>> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73. >>> Use of uninitialized value in integer gt (>) at >>> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 77. >>> >>> Any idea, why I am getting above errors ? >> >> Yes >> >> Because you are not passing the integers required by your >> module Time::Local >> >> You are doing something wrong with your parsing or date extraction. >> >> Do you have a sample code snippet reproduces those errors and >> that you can post here ? > > My code is as follows : > > use strict; > use warnings; > use Time::Local; > > $days1 = epoch_days('30-Jan-09'); > $days2 = epoch_days('16-Feb-09'); > > $day = $days1 - $days2; > > print "Difference: @{[$days1 - $days2]} days\n"; > > 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); > } > }
First of all please start bottom-posting your responses to this. (That is to put your response at the end of the post you are quoting.) It is the standard style here and you will see that all regular contributors adhere to it. You must show us the actual code that gives you the errors you describe. As Chas has pointed out, the above program will not compile, and gives several errors like Global symbol "$days1" requires explicit package name This is because you have 'use strict' at the top of your program and have not declared the three scalar variables. If I change the three lines as follows: my $days1 = epoch_days('30-Jan-09'); my $days2 = epoch_days('16-Feb-09'); my $day = $days1 - $days2; then your program runs fine and produces the output Difference: -17 days We cannot help you if you don't show us the code that has the problem. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/