in reply to Re: Determining the dayname for the last day of any given month
in thread Determining the dayname for the last day of any given month
After reaeding greenFox' comment I realised: Substracting isn't necessary!
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Simply rotate the daynames...#!/usr/bin/perl -w use strict; use Time::Local; while (1) { print "Enter year (yyyy) and month (mm), separated by a space:"; chomp(my $input = <STDIN>); last if !$input; my ($year, $month) = split / /, $input; my $dayname = (qw(Sat Sun Mon Tue Wed Thu Fri))[(gmtime(timegm(0,0 +,0,1,$month % 12,$year + $month / 12)))[6]]; print "The last day of $month/$year will be a $dayname\n"; }
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|
---|
In Section
Seekers of Perl Wisdom