Switch Time : date time « Data Type « Perl






Switch Time

  


#! /usr/local/bin/perl

($second, $minute, $hour, $day_of_month,$month, $year, $weekday, $day_of_year, $daylight_standard_time) = localtime(time);
 SWITCH:{
    if ($hour > 18){
       if ($hour < 21){
          print "Good Evening World\n";
       }else {
          print "Good Night World\n";
       }
      last SWITCH ;
    }
    if ($hour > 12){
      print "Good Afternoon World\n";
      last SWITCH ;
    }
    if ($hour > 6) {
      print "Good Morning World\n";
      last SWITCH ;
    }
    DEFAULT:{
       print "Go to BED already! \n";
       last SWITCH ;
    }
}

   
    
  








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.Time of Day
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