#!/usr/bin/perl use strict; use warnings; use Date::Calc qw(Day_of_Week Days_in_Month); use HTML::Template::Compiled; my $month = 2; my $year = 2007; # nicht jeder monat faengt mit Montag an my $dow = Day_of_Week( $year, $month, 1 ); $dow = 7 if $dow == 1; $dow--; my @array = (' ') x $dow; # bearbeite die tage my @tage; for( @array, 1 .. Days_in_Month($year,$month) ){ push @tage, { TAGESZAHL => $_, CSS => 'irgendein_css', #... }; } # teile in wochen auf my @wochen; my $counter = 0; my @subtage; for my $tag( @tage ){ push @subtage, $tag; if( ++$counter == 7 ){ $counter = 0; push @woche, { WOCHE => [@subtage] }; undef @subtage; } } # template processing my $template = HTML::Template::Compiled->new( filehandle => *DATA ); $template->param( ALLEWOCHEN => \@wochen ); print $template->output; __DATA__