$cal->item( 15, 16, 17 )->wrap_content( font({ size => 4, color => 'red' }) ); #### #!/usr/bin/perl -w use strict; use CGI qw(:standard); use Date::Calc qw(:all); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use lib '/home/users/t/my_site.com-90978/lib'; use HTML::AsSubs; use HTML::Element; use HTML::CalendarMonth; # @dates has already been sorted my @dates = ( 730000, 731158, 731159, 731160, 731161, 731178, 735000 ); my @cals; print header(), start_html(-title => "Calendars"); # As long as there is a date left in @dates while (defined $dates[0]) { # get the first value from @dates leaving @dates alone my $days = $dates[0]; # find out the year, month and day so we can create a calendar my ($year, $month, $day) = Add_Delta_Days(1,1,1, $days - 1); # run the CreateCal subroutine with the year and month from the first date # store the returned value in @dates so it can be used the next time through the while loop @dates = CreateCal($year, $month, @dates); } exit(0); sub CreateCal { # Get the year and month for the calendar # as well as the @dates to use my ($cyear, $cmonth, @dates) = @_; # set up some variables that are local to this subroutine my (@days, @temp); my %calendar; my $new_c; my $t; # Process each $days in @dates foreach my $days (@dates) { # Get the year, month and day of $days my ($year, $month, $day) = Add_Delta_Days(1,1,1, $days - 1); # does it match the calendar we are creating? if ($year == $cyear && $month == $cmonth) { # if yes, then add the $day to @days push (@days, $day); } else { # if no, then add the $days to @temp push (@temp, $days); } } #while there are spare $days remaining if (@temp) { my $new_c = new HTML::CalendarMonth(month => $cmonth, year => $cyear,); #Create hash linking $new_c and @days %calendar = ($new_c => @days); return @temp; #when all $days are used up: } else { # Embolden headers #throw new calendar with @days foreach ($new_c{@days}) { $_->item($_->month,$_->year)->wrap_content(font({size => '2'})); $_->item($_->dayheaders)->wrap_content(font({size => '1'})); $_->item(@days)->wrap_content(font({size => 4, color => 'red'})); # Generate container table my $t = new HTML::ElementTable ( maxrow => 1, maxcol => 6 ); # Populate container table foreach (0..$#cals) { $t->cell(0,$_)->push_content($cals[$_]); } print $t->as_HTML; } } } #There may be a lot of gobbledygook here but I hope it gives an idea of what I'm trying to do with this approach. #Other issue is re-sorting so the calendars are placed in the table in order.