in reply to Seeing if a Time is Within a Range
This looks like 24-hour hh::mm::ss format, if it is strictly followed, what's wrong with a straight 'ge', or 'le'?
use strict; use warnings; print between('02:03:04', '02:03:01', '13:00:24'), "\n"; print between('02:03:04', '02:03:05', '13:00:24'), "\n"; print between('14:03:04', '02:03:01', '13:00:24'), "\n"; print between('14:03:04', '02:03:01', '15:00:24'), "\n"; sub between { my ($t, $begin, $end) = @_; return (($t ge $begin) && ($t le $end)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Seeing if a Time is Within a Range
by Anonymous Monk on Oct 26, 2004 at 20:19 UTC | |
by pg (Canon) on Oct 26, 2004 at 21:21 UTC |