You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Issam W. Alameh" <is...@alameh.net> on 2000/09/08 19:34:56 UTC
init in Apache::ASP
Hello All,
Can I put my asp code at the end of my html page, but let it execute before
showing the html???
I want to have something like
------------------------
Hello <%=$name%>
<%
$name="something";
%>
------------------------
Can this show
Hello something
Regards
Issam
Re: init in Apache::ASP
Posted by Dmitry Beransky <db...@ucsd.edu>.
>At 03:59 PM 9/8/00, G.W. Haywood wrote:
>Try to think of it as a program. You can't use the variable's value
>until you've set it. Why does it matter where it goes in the page?
Not exactly true for Perl, is it? -- the BEGIN subroutine comes to
mind. What follows is just a speculation on my part, hopefully Joshua or
someone else who knows better will correct me if I'm wrong... As I
understand the way ASP code is parsed, everything is converted to a perl
script with patches of HTML replaced by print statements. This perl script
is then submitted to eval(). Assuming this is true, I think you should be
able to use the BEGIN subroutine to initialize your variables just like in
a normal perl script.
Hello <%=$name%>
<%
BEGIN {
$name="something";
}
%>
Of course, if you have variables that need to be initialized for every
script you run, you should probably use Script_OnStart.
Dmitry
PS Perhaps I should've test this first, before talking off my ass.
>If you really want to separate it, use Response->Include or something.
>>
>>On Fri, 8 Sep 2000, Issam W. Alameh wrote:
>>
>> > I want to have something like
>> > ------------------------
>> > Hello <%=$name%>
>> > <%
>> > $name="something";
>> > %>
>> > ------------------------
Re: init in Apache::ASP
Posted by Joshua Chamas <jo...@chamas.com>.
"Issam W. Alameh" wrote:
>
> Hello All,
>
> Can I put my asp code at the end of my html page, but let it execute before
> showing the html???
>
> I want to have something like
>
> ------------------------
> Hello <%=$name%>
> <%
> $name="something";
> %>
> ------------------------
>
> Can this show
>
> Hello something
>
No, probably the place you want to put this code is Script_OnStart
like Dmitry mentioned, where you can set up globals for all of
your scripts. You cannot hide code like Mason by putting it after
the HTML, better to put it into some kind of init() subroutine.
--Joshua
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
Re: init in Apache::ASP
Posted by "G.W. Haywood" <ge...@www.jubileegroup.co.uk>.
Hi there,
On Fri, 8 Sep 2000, Issam W. Alameh wrote:
> I want to have something like
> ------------------------
> Hello <%=$name%>
> <%
> $name="something";
> %>
> ------------------------
Try to think of it as a program. You can't use the variable's value
until you've set it. Why does it matter where it goes in the page?
If you really want to separate it, use Response->Include or something.
73,
Ged.