On Tue, 24 Feb 2009 09:58:00 +0000 "S, Rajini (STSD)" <rajin...@hp.com> wrote:
> > My code in the program is : That all seems to work. If you ever have problems getting a program to work, it is often advisable to add some debugging aids, and I have added a few to your code below so you might get the idea. uninitialized errors, I guess, are mainly caused by passing an undefined value. You have to work back from the error line to then determine why the value is unititialized. Owen use strict; use warnings; use diagnostics; ##### provides a more verbose explanation of errors use Time::Local; my $days1 = epoch_days('30-Jan-09'); my $days2 = epoch_days('16-Feb-09'); my $day = $days2 - $days1; print "Difference: @{[$days2 - $days1]} 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; ##### put print statements every where to see what is happening print "I am expecting to see $dmy[0] $dmy[1] $dmy[2]\n"; return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60); } } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/