Greeting Generator based on Local Time
12
A little function that returns a greeting based on the local time.
sub get_greeting {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
if($hour >= 0 and $hour < 12) { return "Good Morning"; }
elsif($hour >= 12 and $hour < 17) { return "Good Afternoon"; }
elsif($hour >= 17 and $hour < 24) { return "Good Evening"; }
else { return "Welcome"; }
}






However, the memory savings would not be measurable unless this script runs a ton.
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
my $hour = (localtime(time))[2];