You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Thom Crane <ma...@thomcrane.com> on 2002/10/05 18:09:30 UTC

Regarding subs and global.asa

Hello all,
	I am sure this is quite the newbie question, but alas, a newbie I am :)

	I keep getting errors that say I am trying to use an undefined sub.  The
error (regardless of which sub it points out) is in the following form in
the error log:

<quote>

[Sat Oct  5 08:34:24 2002] [error] [asp] [2246] [error] Undefined subroutine
&Apache::ASP::Compiles::__ASP__tmpx9936a616c549519afe239b14a8568b6c::mysub
called at index.asp line 210. <--> ,
/usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pm line 1413

</quote>

In this case, I am calling the sub in this manner in the program:

	&mysub()

My global.asa is set up as follows:

#global.asa

	sub mysub{

		...lots o' code...
	}

I have tried with all my might to find the answer to this conundrum on the
web site and archives, but I am newbie enough not to be able to put together
the clues...

Any ideas, comments, tongue-lashings? <g>

Thanks in advance,

Thom Crane






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


Re: Regarding subs and global.asa

Posted by Josh Chamas <jo...@chamas.com>.
Thom Crane wrote:
> Where is PerlSetVar defined?  I don't have access to the server, therefore I
> can make no changes to httpd.conf.  Can I define it in .htaccess?
> 

At least on my server, I can add PerlSetVar configs to .htaccess.

--Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


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


RE: Regarding subs and global.asa

Posted by Thom Crane <ma...@thomcrane.com>.
Where is PerlSetVar defined?  I don't have access to the server, therefore I
can make no changes to httpd.conf.  Can I define it in .htaccess?

Thom

-----Original Message-----
From: Josh Chamas [mailto:josh@chamas.com]
Sent: Sunday, October 06, 2002 1:42 PM
To: Thom Crane
Cc: asp@perl.apache.org
Subject: Re: Regarding subs and global.asa


Thom Crane wrote:
> Please forgive my hastiness to get this problem solved.
> 	I have used require "global.asa" to get my problem worked out, but this
> doesn't seem to be the proper way of handling this file from the reading I
> have done.
> 	Although not stated explicitly, it has been my feeling from reading at
the
> site and on this list that global.asa has some higher purpose than just
> being another include file.

As dave pointed out, this is where the ASP events definitions reside.
However, since the global.asa is also compiled into the same perl
package as the rest of the scripts & includes in your application,
common subroutines & globals can be defined in there too for use
in your application.

The trick with getting global.asa to be compiled is your PerlSetVar Global
setting needs to point to the location it resides at.  If your
global.asa resides in the same directory as your scripts, then set
Global to .   If you would like your $Session & $Application files
not stored in ./.state in this case ( the default ), then you can
set StateDir to some other directory ( like /tmp/my_asp_app )

> Is using a require the proper way to handle this?  If not, would some kind
> soul (who has nothing better to do this weekend), please help out a
> burgeoning Apache::ASP user with some basics?

Doing a require on global.asa has a similar effect, but you should allow
for Apache::ASP to reload your global.asa, which it will do correctly
whenever you change it.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com




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


Re: Regarding subs and global.asa

Posted by Josh Chamas <jo...@chamas.com>.
Thom Crane wrote:
> Please forgive my hastiness to get this problem solved.
> 	I have used require "global.asa" to get my problem worked out, but this
> doesn't seem to be the proper way of handling this file from the reading I
> have done.
> 	Although not stated explicitly, it has been my feeling from reading at the
> site and on this list that global.asa has some higher purpose than just
> being another include file.

As dave pointed out, this is where the ASP events definitions reside.
However, since the global.asa is also compiled into the same perl
package as the rest of the scripts & includes in your application,
common subroutines & globals can be defined in there too for use
in your application.

The trick with getting global.asa to be compiled is your PerlSetVar Global
setting needs to point to the location it resides at.  If your
global.asa resides in the same directory as your scripts, then set
Global to .   If you would like your $Session & $Application files
not stored in ./.state in this case ( the default ), then you can
set StateDir to some other directory ( like /tmp/my_asp_app )

> Is using a require the proper way to handle this?  If not, would some kind
> soul (who has nothing better to do this weekend), please help out a
> burgeoning Apache::ASP user with some basics?

Doing a require on global.asa has a similar effect, but you should allow
for Apache::ASP to reload your global.asa, which it will do correctly
whenever you change it.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


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


Re: Regarding subs and global.asa (from one newbie to another)

Posted by dave_apache_asp <da...@yahoo.com>.
Thom:

I think global.asa is only supposed to contain event-triggered 
(*_On*) subroutines and maybe local subs called by the _On subs.  The 
best place I've found for non-event-triggered subs is in separate 
modules.  You can pre-load and pre-compile frequently used modules in 
Application_OnStart though and then refer to them from any page.  
Application_OnStart is only for GLOBAL stuff though, and I think 
changes require an Apache restart (in contrast to Script_OnStart, 
which is apparently re-compiled/executed every time).  This also 
means changes to the modules being loaded will require an Apache 
restart since they are only loaded and compiled once.  (I could be 
wrong as I'm not the expert; this is just the behavior I've observed.)

For example, part of my global.asa might look like this.

#global.asa
sub Application_OnStart {

  use InputProcessor;
  use UserCheck;

  # read in global config params (e.g. db connect strings)
  open (CFG, '/outside/of/web/tree/app.cfg');
  while (<CFG>) {
    chomp;
    my ($key, $value) = split;
    $Application->{$key} = $value;
  }
  close CFG;
}

Then, for example, in login.asp I just say

#login.asp
...(html)...
<%
  my $userCheck = new UserCheck;
  if ($userCheck->checkUser($ASPObjects)) {
    $Response->Redirect(...)
  }
  else { #...etc.
%>

hope this helps!  If not, at least I tried :)

-dave
--- In apache-asp@y..., "Thom Crane" <ma...@t...> wrote:
> Please forgive my hastiness to get this problem solved.
> 	I have used require "global.asa" to get my problem worked 
out, but this
> doesn't seem to be the proper way of handling this file from the 
reading I
> have done.
> 	Although not stated explicitly, it has been my feeling from 
reading at the
> site and on this list that global.asa has some higher purpose than 
just
> being another include file.
> 
> Is using a require the proper way to handle this?  If not, would 
some kind
> soul (who has nothing better to do this weekend), please help out a
> burgeoning Apache::ASP user with some basics?
> 
> Thanks so much.
> 
> Thom
> 
> -----Original Message-----
> From: Thom Crane [mailto:mail@t...]
> Sent: Saturday, October 05, 2002 11:10 AM
> To: asp@p...
> Subject: Regarding subs and global.asa
> 
> 
> Hello all,
> 	I am sure this is quite the newbie question, but alas, a 
newbie I am :)
> 
> 	I keep getting errors that say I am trying to use an 
undefined sub.  The
> error (regardless of which sub it points out) is in the following 
form in
> the error log:
> 
> <quote>
> 
> [Sat Oct  5 08:34:24 2002] [error] [asp] [2246] [error] Undefined 
subroutine
> 
&Apache::ASP::Compiles::__ASP__tmpx9936a616c549519afe239b14a8568b6c::m
ysub
> called at index.asp line 210. <--> ,
> /usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pm line 1413
> 
> </quote>
> 
> In this case, I am calling the sub in this manner in the program:
> 
> 	&mysub()
> 
> My global.asa is set up as follows:
> 
> #global.asa
> 
> 	sub mysub{
> 
> 		...lots o' code...
> 	}
> 
> I have tried with all my might to find the answer to this conundrum 
on the
> web site and archives, but I am newbie enough not to be able to put 
together
> the clues...
> 
> Any ideas, comments, tongue-lashings? <g>
> 
> Thanks in advance,
> 
> Thom Crane
> 
> 
> 
> 
> 
> 
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: asp-unsubscribe@p...
> For additional commands, e-mail: asp-help@p...
> 
> 
> 
> 
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: asp-unsubscribe@p...
> For additional commands, e-mail: asp-help@p...


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


RE: Regarding subs and global.asa

Posted by Thom Crane <ma...@thomcrane.com>.
Please forgive my hastiness to get this problem solved.
	I have used require "global.asa" to get my problem worked out, but this
doesn't seem to be the proper way of handling this file from the reading I
have done.
	Although not stated explicitly, it has been my feeling from reading at the
site and on this list that global.asa has some higher purpose than just
being another include file.

Is using a require the proper way to handle this?  If not, would some kind
soul (who has nothing better to do this weekend), please help out a
burgeoning Apache::ASP user with some basics?

Thanks so much.

Thom

-----Original Message-----
From: Thom Crane [mailto:mail@thomcrane.com]
Sent: Saturday, October 05, 2002 11:10 AM
To: asp@perl.apache.org
Subject: Regarding subs and global.asa


Hello all,
	I am sure this is quite the newbie question, but alas, a newbie I am :)

	I keep getting errors that say I am trying to use an undefined sub.  The
error (regardless of which sub it points out) is in the following form in
the error log:

<quote>

[Sat Oct  5 08:34:24 2002] [error] [asp] [2246] [error] Undefined subroutine
&Apache::ASP::Compiles::__ASP__tmpx9936a616c549519afe239b14a8568b6c::mysub
called at index.asp line 210. <--> ,
/usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pm line 1413

</quote>

In this case, I am calling the sub in this manner in the program:

	&mysub()

My global.asa is set up as follows:

#global.asa

	sub mysub{

		...lots o' code...
	}

I have tried with all my might to find the answer to this conundrum on the
web site and archives, but I am newbie enough not to be able to put together
the clues...

Any ideas, comments, tongue-lashings? <g>

Thanks in advance,

Thom Crane






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




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