Here is something even simpler. Possibly too simple:
#!/usr/bin/perl -wl use strict; # Get the month using cal my @cal = `cal @ARGV`; my $date = shift @cal; $date =~ s/^\s+//; $date =~ s/\s+$//; shift @cal; # Ignore short day names pop @cal; # Ignore blank row unshift @cal, 'Sun Mon Tue Wed Thu Fri Sat'; # Add days # Some simple Html formatting print '<html>'; print '<head>'; print '<center>'; print '<table border="1">'; print "\t<tr>\n\t\t<td colspan=\"7\">" . "<center>$date</center></td>\t\n</tr>"; # Print each day as a <td> element for (@cal) { print "\t<tr>"; my @days = split ' '; # Left or right pad short weeks if (@days < 7) { if ($days[0] == 1) { unshift @days, ('&nbsp;') x (7 -@days); } else { push @days, ('&nbsp;') x (7 -@days); } } print "\t\t<td>$_</td>" for @days; print "\t</tr>"; } print '</table>'; print '</center>'; print '</head>'; print '</html>'; __END__

It uses the Unix cal utility to generate the months and it takes month and year as optional arguments. Here is some sample output, add formatting to taste:

    perl html_cal.pl

June 2003
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

    perl html_cal.pl 5 2003

May 2003
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

--
John.


In reply to Re: Something simpler than HTML::Calendar::Simple by jmcnamara
in thread Something simpler than HTML::Calendar::Simple by oakbox

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.