Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Simple calendarby perl_fool (Initiate) |
on Mar 08, 2010 at 01:41 UTC ( [id://827299]=perlquestion: print w/replies, xml ) | Need Help?? |
perl_fool has asked for the wisdom of the Perl Monks concerning the following question: Hello. I would like to create a calendar using perl programming. The program should accept the year input by user and also the the day of the week for January 1 of that particular year (1=sunday; 7=saturday). example if i key in 1 for the day input, Jan 1 should be in sunday; if i key in 2, Jan 1 should be monday.
I've looked through the calendar examples in this website but it's too hard for me, especially the use of local time function..I need some help here, below it's the guideline given by my lecturer, which i don't think it's gonna work.. <code> foreach (1..12) { #12 months if (day==1) { #if it's sunday print "\t\t\t\t\t\t\t1\n"; $date=2; #next date will start with 2 } } foreach (1..5) { # 5 weeks in a month foreach (1..7) { #7 days in a week print "\t$date"; $date++; print "\n\n"; } } if (day=2) { # if it's a monday print "1\t2\t3\t4\t5\t6\t7\n"; $date=8; .......#continue to type for 7 days <code> i know this program looks stupid but I do really need help with this. How to write codes so that the days do not exceed 28/29/30/31 days per month? and also leap year?? and how to decide the next day for the next new month?? thanks for anyone who help!! (sorry i dunno the html formatting)
Back to
Seekers of Perl Wisdom
|
|