in reply to if && condition not working
Sounds like the dates are in the yyyy/mm/dd format, so why not just compare the strings with lt/gt?
sub validate_date { my ($start_date, $end_date, $today) = @_; return "Invalid format for start date (expecting yyyy/mm/dd)" if $start_date !~ m{^\d{4}/\d{2}/\d{2}\z}; return "Invalid format for end date (expecting yyyy/mm/dd)" if $end_date !~ m{^\d{4}/\d{2}/\d{2}\z}; return "End date must be no later than today" if $end_date gt $today; return "Start date must be no later than end date" if $start_date gt $end_date; return ""; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if && condition not working
by rakheek (Sexton) on Mar 24, 2010 at 21:36 UTC | |
by ikegami (Patriarch) on Mar 24, 2010 at 23:45 UTC |