Loading ...
Sorry, an error occurred while loading the content.

1213Re: Main (global.asa) Package Variables

Expand Messages
  • Josh Chamas
    May 19, 2003
      Mike Witkowski wrote:
      > Hello again:
      > If I have some variables in the main package (global.asa) then
      > use them ($main::<some_var>) in several asp pages, do their
      > values persist between pages with the same session ID?

      No, global variables persist on a per httpd process basis, and it is
      good to garbage collect them explicitly like this:

      $main::DATA = { ... };
      $Server->RegisterCleanup(sub { $main::DATA = undef });

      This way the memory can be freed when your request is done processing.
      You might also put this into the Script_OnEnd of the global.asa.

      > been bit by non-persistence (between pages) several times before
      > and have gone the route of throwing everything I need into the
      > $Session Object. From what I've been reading, this may not be
      > an efficient way to go (comments?). Cleaning up the $Session
      > Object seems to be a pain also. Is there any-way to clean it
      > up without clearing the entire Session?

      Data in $main::XXX has little to do with $Session, except when you
      are talking about ASP objects like $main::Session. Yes it is inefficient
      to store lots of things in $Session. Store only what you have to
      to persist from page to page. Note, that you do not have to clean
      up $Session, Apache::ASP does that for you each request.

      > If this is he case, I am assuming that the contents of these
      > variables are different between different sessionID's (?). I
      > have also picked up the inference that I might be able to get
      > all my modules compiled into the main package. Other than
      > defining all of my routines in that package, how can that be
      > done? The application I am writing is quite large and depends
      > partially on modules I've written for other applications.

      Proper module usage and encapsulation mean that you don't want to do
      what you suggest, by having everything in the main namespace.
      You can have any module export subroutines if you like to any other
      package or script, please see "perldoc Exporter" for more information
      on this. Also if you define subroutines in your global.asa, they will
      be seen in all of you scripts since your scripts are merely compiled
      as subroutines in the same package as your global.asa


      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@...
      For additional commands, e-mail: asp-help@...
    • Show all 2 messages in this topic