Without any real testing, may I suggest that the $date in the localtime 
call be surrounded in parens? Whenever I have dealt with localtime, I 
have found it to be finicky about that. Probably won't fix your current 
problem, but can save you headaches later.

--Jon R.

Dermot Paikkos wrote:

> Hi
> I have the following sub in a script:
> 
> use Apache::Constants qw(OK NOT_FOUND);
> use Apache::Request;
> use Apache::Template;
> use strict;
> 
> 131  sub week {
> 132    my $date = time();
> 133    my ($monthday,$weekday,$yearday)=(localtime $date)[3,6,7];
> 134    (my $weeknum) = int($yearday / 7) + 1;
> 135    return ($weeknum,$yearday,$date,$monthday);
> 136  }
> 
> I confess I stole it straight out of the perl cookbook - bighorn sheep - 
> and it should return the week number of the year. It doesn't. $date is 
> set but all the other vars are uninitialized (expect the + 1 of course) 
> so I end up with the week as 1.
> 
> I tried this as a snippet on its own and it works. I can't figure out why 
> it doesn't with mod_perl. I was a bit unsure of whether $date = 
> time(); should be scalar or an array but neither work.
> 
> I have a feeling I am doing something (Dooh) stupid here. Can 
> anyone spot a mistake?
> Thanx.
> Dp.
>  
> 
> ~~
> Dermot Paikkos * [EMAIL PROTECTED]
> Network Administrator @ Science Photo Library
> Phone: 0207 432 1100 * Fax: 0207 286 8668
> 
> 
> 


Reply via email to