7stud has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I am trying to compare two dates with no luck:
use strict; use warnings; use 5.010; use Date::Manip; use Date::Manip::Date; my $date1 = Date::Manip::Date->new; my $date2 = Date::Manip::Date->new; my $format = "%Y--%m--%d"; my $error1 = $date1->parse_format($format, "2010--03--30"); my $error2 = $date2->parse_format($format, "2010--03--31"); say $error1; say $error2; if ($error1 == 0 and $error2 == 0) { #then successfully parsed dates my $flag = Date_Cmp($date1, $date2); say $flag; } --output:-- 0 0 Use of uninitialized value $flag in say at 1perl.pl line 21.
I expected $flag to be an integer less than 0, 0, or greater than 0. What am I doing wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date::Manip can't get Date_Cmp to work
by SBECK (Chaplain) on Apr 01, 2010 at 11:15 UTC | |
by 7stud (Deacon) on Apr 01, 2010 at 19:46 UTC | |
|
Re: Date::Manip can't get Date_Cmp to work
by ikegami (Patriarch) on Apr 01, 2010 at 04:03 UTC | |
by 7stud (Deacon) on Apr 01, 2010 at 05:12 UTC | |
by ikegami (Patriarch) on Apr 01, 2010 at 05:28 UTC |