The range operator and foreach loop
foreach $hour (1 .. 24){ if ($hour > 0 && $hour < 12) { print "Good-morning.\n"; } elsif ($hour == 12) { print "Happy Lunch.\n"; } elsif ($hour > 12 && $hour < 17) { print "Good afternoon.\n"; } else { print "Good-night.\n"; } }