Time of Day : date time « Data Type « Perl






Time of Day

  

#! /usr/local/bin/perl

($sec, $min, $hr, $dayOfMonth, $month, $yr,$weekday, $dayOfYear, $dayLightStandardTime) = localtime(time);
if ( ($month == 11) && ($dayOfMonth == 23 || $dayOfMonth == 24) ){
   print "Merry Christmas World \n";
}
else {
    if ($hr > 18){
      if ($hr < 21){
         print "Good Evening World\n";
      }else {
         print "Good Night World\n";
      }
    }elsif ($hr > 12){
       print "Good Afternoon World\n";
    }elsif ($hr > 6) {
        print "Good Morning World\n";
    }else {
        print "Go to BED already! \n";
    }
}

   
    
  








Related examples in the same category

1.To extract the current date by using time and localtime
2.Set the value of localtime to a scalar variable, you'll get a typical UNIX-style time
3.scalar(localtime(time()))
4.Splitting Time
5.Create new time based on the value from localtime
6.Print out the current time in standard time
7.Is leap year subroutine
8.Execute date command and get user input
9.Switch Time
10.Converting Time
11.Splitting Local Time
12.localtime converts a time into the local time.
13.gmtime function converts a time value into Greenwich Mean Time