#!/usr/bin/perl use strict; use warnings; # time off: 1800 - 0600 6PM to 6AM my $hour = (localtime(time))[2]; if ($hour >= 06 and $hour <= 18) { turn_on_lights(); #day time } else #18:01 to 05:59 avoids the hour 00 discontinuity { turn_off_lights(); #night time }