perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nate Smith <n...@thebackrow.net>
Subject Subroutine problem
Date Mon, 07 Jun 2004 22:19:21 GMT

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 \@week;
}

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 \@month;
}

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 

Mime
View raw message