We don't bite newbies here... much PerlMonks

### Comment on

 Need Help??
Another solution without using any module:
```#!/usr/bin/perl -w
use strict;

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 \$m= \$month % 12 + 1;
my \$y= \$year+int(\$month/12);
if ( \$m<3) {
\$m+=12;
--\$y;
}
++\$m;
my \$dayname = (qw(Sat Sun Mon Tue Wed Thu Fri))[(int(\$m * 30.6) +
+int(\$y * 365.25)-int(\$y / 100)+int(\$y / 400)) % 7];

print "The last day of \$month/\$year will be a \$dayname\n";
}
The formular used here works like this:
1. if the month is January or february (1 or 2) shift it to the end of the preceeding year (month 13 and 14)
2. add 1 to the month
3. sum up the integer result of:
1. month * 30.6
30.6 gives it the correct toggle between 30 and 31. February is the last month, so no problem with 28/29
2. year * 365.25
this takes into account the leap years
3. year / -100
this subtracts the non-leap years
4. year / 400
4. the day should then be added
the reminder of 7 is the weekday starting with Sat==0

s\$\$([},&%#}/&/]+}%&{})*;#\$&&s&&\$^X.(\$'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`\$''`"e

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2018-06-25 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (128 votes). Check out past polls.

Notices?