Blob


1 #!/usr/bin/perl
3 # Write a program to parse the output of the date command to
4 # determine the current day of the week. If the day of the week is
5 # a weekday, print 'get to work'; otherwise, print 'go play'. The
6 # output of the date command begins with Mon on a Monday. If you
7 # don't have a date command on your non-Unix system, make a fake
8 # little program that simply prints a string like date might print.
9 # We'll even give you this two-line program if you promise not to
10 # ask us how it works:
11 #
12 # #!/usr/bin/perl
13 # print localtime( ). "\n";
15 use v5.24;
16 use warnings;
17 use strict;
18 use utf8;
20 if (`date` =~ /(\w{3}) (\w{3}) (\d{1,2}) (\d{1,2}:\d{1,2}:\d{1,2}) (\w{2,4}) (\d{4})/) {
21 my ($weekday, $mon, $day, $time, $zone, $year) = ($1, $2, $3, $4, $5, $6);
22 if ($weekday =~ /Sat|Sun/i) {
23 print "Go play!\n";
24 } else {
25 print "Get to work!\n";
26 }
27 }