I've read through the docs and the archive to no avail..
I'm creating a calendar with some functions like this:
sub get_week{
local ($y, $m, $d) = @_;
local %week = (); # HoH's for our week
local $dotw = Day_of_Week($y, $m, $d);
local ($monday_y, $monday_m, $monday_d) = Add_Delta_Days($y, $m, $d, -($dotw-1));
for (my $i=0; $i<7; $i++) {
local ($week[$i]{'y'}, $week[$i]{'m'}, $week[$i]{'d'}) =
Add_Delta_Days($monday_y, $monday_m, $monday_d, $i);
}
return [EMAIL PROTECTED];
}
sub get_month{
local ($y, $m) = @_;
local $ditm = Days_in_Month($y, $m);
local @month = ();
local $d = 1;
WEEK: for(my $i=0; $i<=5; $i++) {
$month[$i] = get_week($y, $m, $d);
last WEEK if (($month[$i][6]{m} > $m) ||
($month[$i][6]{y} > $y));
$d = ( (($d+7) > $ditm) ? ($ditm) : ($d+7) );
}
return [EMAIL PROTECTED];
}
so that my page looks something like this:
[-
+-- 18 lines: sub get_week{---- (see above)
+-- 21 lines: sub get_month{--- (see above)
-]
[$ sub month_cal $]
[-
my ($y, $m) = @_;
my @months = qw('' January February March
April May June July
August September October
November December);
my @days = qw(Mon Tue Wed Thu Fri Sat Sun);
$month = get_month($y, $m);
#print OUT Dumper \$month;
-]
<table width="100%" border=1 cellspacing=2 cellpadding=2 align="center">
<tr>
<td colspan="7">
<table width="100%" border=0 cellspacing=0 cellpadding=0 align="center">
<tr>
<td align="center"> </td>
<td align="center"> <font size=4> [+ $months[$m] +] </font></td>
<td align="center"> </td>
</tr>
</table>
</td>
</tr>
<tr>
[$ foreach $dow @days $]
<td align="center"> [+ $days[$dow] +] </td>
[$ endforeach $]
</tr>
[$ foreach $week @{$month} $]
<tr>
[$ foreach $day @{$month[$week]} $]
<td> [+ $month[$week][$day]{d} +] </td>
[$ endforeach $]
</tr>
[$ endforeach $]
</table>
[$ endsub $]
<snip out HTML>
[- month_cal('2004','6') -]
<more HTML snipped>
Now, the output from Data::Dumper looks like:
$VAR1 = \[ [ {}, {}, {}, {}, {}, {}, {} ], ${$VAR1}->[0], ${$VAR1}->[0],
${$VAR1}->[0], ${$VAR1}->[0], ${$VAR1}->[0] ];
with no values.
I have a test script working correctly, also attached. This is the same code,
cut/pasted and embperl'd.
Anybody have any idea why I can't do something like this?
I'm calling an Embperl function which calls another function, which in turn calls one
other function 4-5 times, to
build a data structure of the days that should appear on a calendar.
Help!
Nate Smith
#!/usr/bin/perl
#
use strict;
use Date::Calc qw(:all);
# my $y = 2004;
# for (my $m=1; $m<=12; $m++){
my ($y, $m, $d) = (localtime(time))[5,4,3];
$y+= 1900;
$m++;
get_month ($y,$m);
my $month = get_month($y, $m);
for(my $week=0; $week<@{$month}; $week++) {
print "$m/$y Week $week : \n";
for(my $day=0; $day<@{${$month}[$week]}; $day++) {
print "${$month}[$week][$day]{dayname}, ${$month}[$week][$day]{m}/${$month}[$week][$day]{d}/${$month}[$week][$day]{y}\n";
}
print "\n";
}
#}
sub get_month {
my ($y, $m) = @_;
# How many Days In This Month?
my $ditm = Days_in_Month($y, $m);
# month: an Array of Arrays?
my @month = ();
# Now get the weeks..
my $d = 1;
WEEK: for(my $i=0; $i<=5; $i++) {
$month[$i] = get_week($y, $m, $d);
last WEEK if (($month[$i][6]{m} > $m) ||
($month[$i][6]{y} > $y));
$d = ( (($d+7) > $ditm) ? ($ditm) : ($d+7) );
}
return [EMAIL PROTECTED];
}
sub get_week {
my ($year, $month, $day) = @_;
my @week = ();
my $dotw = Day_of_Week($year, $month, $day);
my ($monday_y, $monday_m, $monday_d) = Add_Delta_Days($year, $month, $day, -($dotw-1));
for (my $i=0; $i<7; $i++) {
($week[$i]{'y'}, $week[$i]{'m'}, $week[$i]{'d'}) = Add_Delta_Days($monday_y, $monday_m, $monday_d, $i);
my $dotw = Day_of_Week($week[$i]{'y'}, $week[$i]{'m'}, $week[$i]{'d'});
$week[$i]{'dayname'} = ('','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')[$dotw];
}
return [EMAIL PROTECTED];
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]