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
    Thanks, Ikegami. I will use the string comparison. Do you know if I need to get rid of the / in the date? I can give it a try. Regards, Rakhee
      "/" equals "/", so no need to remove them. gt performs a string comparison, not a numerical one.