perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "D. L. Fox" <d...@netpath.net>
Subject Re: ASP testing troubles
Date Mon, 01 Dec 2003 06:07:43 GMT
> Apache keeps spitting out this error in the logfile:
>
> [Sun Nov 30 16:06:57 2003] [error] [asp] [29743] [error] Undefined
> subroutine

> I have no idea what it means but here is the test page [test.asp]:

>    The time And date is now <%=now()%>

ASP is interpreting the now() as a call to a subroutine - which you haven't
defined.  It's best not to use subroutines directly in your ASP pages
anyway.  Also, you can't call a sub using the = sign because that's for
variable interpolation.

If you intended now() as a function, neither ASP nor Perl has a now()
function that I know of.  You would have to use the Perl time function -
with its localtime, gmtime siblings - to get what you want.

# got this straight from the perl docs
(
    $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst
) = localtime(time);

# and don't forget to:
$mon++;
$year += 1900;

if you're gonna use the dates.  You can stick 'em in a scalar any ol' way
you want it:

my $curtime = $hour.':'.$min.':'.$sec;
my $curdate = $mon.'/'.$mday.'/'.$year;

In ASP, you can write it:

<%=$curtime%> and <%=$curdate%>

And I'm willing to bet there are a number of folks on this list much more
knowledgeable than I who will chime in with some even better suggestions.
So now I'm gonna sit back and LEARN!  :)

Perl docs on time, localtime, and gmtime:

http://www.perldoc.com/perl5.6/pod/func/time.html

http://www.perldoc.com/perl5.6/pod/func/localtime.html

http://www.perldoc.com/perl5.6/pod/func/gmtime.html


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message