in reply to HTML calendar w/dates = links

You will need to cast $dd to an int in order for setdatehref() to actually work on zero padded numbers (it doesn't like leading zeroes):
$dd = int(substr($date,6,2));
Also, you are creating a new HTML::CalendarMonthSimple object with each iteration of the while loop. You will need to change that to read the first line from <DATA> first, then create the table, then add the links:
my $line = <DATA>; ($yyyy,$mm) = $line =~ /\.(\d{4})(\d\d)/; $cal = new HTML::CalendarMonthSimple('month'=>$mm,'year'=>$yyyy); do { chomp $line; ($file, $date) = split('\.', $line); $dd = int(substr($date,6,2)); $cal->setdatehref($dd, "/home/trixee/cal.txt",); } while ($line = <DATA>); print $cal->as_HTML();

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: HTML calendar w/dates = links
by Tuna (Friar) on Aug 13, 2002 at 03:15 UTC
    blink makes a good point, below
Re: (jeffa) Re: HTML calendar w/dates = links
by Anonymous Monk on Aug 13, 2002 at 15:15 UTC
    Well, yes, this is a problem. I've tried mucking around with blink's hash idea, but I can't get the program to:

    - create a new date/link each time a new dated file is found
    - create a new calendar each time a new month is encountered

      Piece of cake, but you might want to read up on perlman:perldsc first. This example also takes care of new years too:
      use CGI qw(header); use HTML::CalendarMonthSimple; use strict; my %cal; while (<DATA>) { chomp; my ($file,$yyyy,$mm,$dd) = /([^.]+)\.(\d{4})(\d\d)(\d\d)/; push @{$cal{$yyyy}->{$mm}},{day => $dd, targ => $file}; } print header; for my $year (sort keys %cal) { for my $mon (sort keys %{$cal{$year}}) { my $cal = HTML::CalendarMonthSimple->new( month => $mon, year => $year, ); for (sort @{$cal{$year}->{$mon}}) { $cal->setdatehref(int($_->{day}), $_->{targ}); } print $cal->as_HTML(); } } __DATA__ file5.20030227 file2.20020802 file1.20020801 file4.20021015 file3.20020803

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)