in reply to Modules not going out of scope

What sort of scope do you create these objects in? Are they my or what?

dave hj~

Replies are listed 'Best First'.
Re: Re: Modules not going out of scope
by ropey (Hermit) on Feb 19, 2002 at 15:06 UTC
    Thanks for your reply Dave I use strict, warnings on, the objects are created within a sub using 'my'. I stripped down the script to see what was going on but to no avail.
    #!/usr/bin/perl -w use CGI; use Session; use Community; use CGI::Carp; main(); sub main { my $query = new CGI; my $uri = 'www.moonfruit.com'; setup($uri, $query); } sub setup { my ($uri, $query) = @_; my $dbh = db_connect(); my $session= new Session($dbh, $query, "guest", $uri); my $community = new Community($session); print $query->header(); return; }
    So the objects should go out of scope once the sub has finished. However as I mentioned they don't automatically get 'destroyed'. I know this as the DESTROY method of the objects are not called, they are however called when I stop the server.
      This part of your code looks okay. It's possible that you have either circular references between objects, or a problem with closures. Problems with closures under Apache::Registry happen when you have a lexical variable declared outside the scope of a subroutine that uses it. This code above doesn't have that problem, but your real code might.