#!/usr/bin/perl -w use CGI qw(:all); use Date::Calc qw(Days_in_Month Day_of_Week Month_to_Text); print "Content-type:text/html\n\n"; my $Path="/home/public/davis/calender_2month.htm"; my %EMB = (); my $i; &getmonthvalue; exit(0); sub getmonthvalue { my $year=param("year"); my $month=param("month"); if(!$year) { $year = 2010; } if(!$month) { $month=1; } &monthvalue($month,$year,0); if($month >= 12) { $month = 1; $year = $year + 1; }else{ $month = $month + 1; } &monthvalue($month,$year,42); &buildnextprevious($month,$year,); print &printFile($Path, \%EMB); } sub monthvalue { my $month = shift; my $year = shift; $i = shift; my $monthtotext = Month_to_Text($month); my $noofdays = Days_in_Month($year,$month); my $dayofweek = Day_of_Week($year,$month,1); $EMB{"mnth$i"} = $monthtotext; $EMB{yr}=$year; $EMB{nextyr}=$year; $noofdays = $noofdays + $i; for(my $j=$i,$k=1;$j < $noofdays;$j++,$k++){ $EMB{$j + $dayofweek} = $k; } } sub buildnextprevious { my $newmonth = shift; my $newyear=shift; # NEXT SECTION if($newmonth == 1) { $EMB{yr} = $newyear - 1; } $EMB{Next} = qq( <a href="/cgi-bin/davis/calender_2month.pl?month= +$newmonth&year=$newyear">Next</a>); # PREVIOUS SECTION if($newmonth == 2) { $newyear = $newyear-1; $newmonth = 14; }if($newmonth == 1) { $newyear = $newyear - 1; $newmonth = 11; }else{ $newmonth = $newmonth - 2; } $EMB{Previous} = qq( <a href="/cgi-bin/davis/calender_2month.pl?mo +nth=$newmonth&year=$newyear">Previous</a>); } sub printFile { my $readFile = shift; my $storeHashRef = shift; my $retFile=""; open (TEMPLATE, $readFile) or die "Open failed for template file * +* $readFile **"; my $Line = ""; while (<TEMPLATE>) { if(/\^/) { $Line = $_; while($Line =~ s/\^(\w*)\^//) { if (!defined $$storeHashRef{$1}) { $$storeHashRef{$1}=""; } } s/\^(\w*)\^/$$storeHashRef{$1}/g; } $retFile .= $_; } close (TEMPLATE); return $retFile; }# end of : sub printFile {

In reply to How do i select the past date and highlight the current date?my code is by Perl_davis

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.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.