Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Well here's one way to modify it (take advantage of CGI.pm's table generating capabilities, and use map -- don't wanna look at Date::Calc at the moment, maybe tomorrow ;D)
#!/usr/bin/perl -w use strict; use Data::Dumper; use Date::Calc qw( Delta_Days Add_Delta_Days Date_to_Text ); use CGI; my $q = new CGI; sub date_range { my(@date) = (@_)[0,1,2]; my(@list); my($i); my $output = ''; my $date; my %POS = (Su=>1, Mo=>2, Tu=>3, We=>4, Th=>5, Fr=>6, Sa=>7 ); $i = Delta_Days(@_); while ($i-- >= 0) { push( @list, [ @date ] ); @date = Add_Delta_Days(@date, 1) if ($i >= 0); } #build the matrix to hold the days. my @box; #the arrray to hold the calendar data my $row=0; foreach $date (@list) { my $col = $POS{substr(Date_to_Text(@{$date}),0,2)}; $box[$row][$col]= (@{$date}[2]); $row++ if ($col == 7); } ## for the header ##   is in here because array indices start at 0, not one ## and I didn't feel like modifying your code above (-1) $output.= $q->Tr( [ $q->th( [ qw(   Su Mo Tu We Th Fr Sa) ] ) ] ); ## gets warnings, since you don't init the array #$output.= join '', map { $q->Tr( [ $q->td( [ @{$_} ]) ] ) } @box +; ## no warnings, cause i test for definedness $output.= join '', map { $q->Tr( [ $q->td( [ map { defined $_ ? $_ :" " } @{$_} ,] ,) ,] ,) } @box; } print $q->header(); ## since => is just a fancy comma, print $q->table( &date_range(2001,11,1 => 2001,11,30) ); ## or for even "better" readability print $q->table( &date_range(qw/2001 11 1/ => qw/2001 11 30/) ); __END__ Yielding the following:
Content-Type: text/html; charset=ISO-8859-1
  Su Mo Tu We Th Fr Sa
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

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


In reply to (crazyinsomniac) Re: Web month Calander by crazyinsomniac
in thread Web month Calander by Ryszard

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-16 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found