On Sat, Aug 26, 2000 at 05:22:27PM +0200, Stas Bekman wrote:

: The following is a known kludge, but it doesn't seem to apply in your
: case (I thought you might use it in PerlHandler)
: 
: =head1 More package name related issues
: 
: If you have the following:
: 
:   PerlHandler Apache::Work::Foo
:   PerlHandler Apache::Work::Foo::Bar
: 
: And you make a request that pulls in C<Apache/Work/Foo/Bar.pm> first,
: then the C<Apache::Work::Foo> package gets defined, so mod_perl does
: not try to pull in C<Apache/Work/Foo.pm>

Yes, I read that.  I don't know if the issue is one in the same.
Because they are in the same file, Object.pm is definitely being
loaded first.  However, what happens differently when a module is
loaded at initial startup versus when the same module is loaded
when a script runs?

: > : > I have a module with some code like this:
: > : >
: > : >   package Object;
: > :
: > : =>  use Object::SubObj;
: > : 
: > : >   sub new {
: > : >     my $class = shift;
: > : >     return bless {}, $class;
: > : >   }
: > : >
: > : >   sub SubObj {
: > : >     Object::SubObj->new();
: > : >   }
: > : >
: > : >   package Object::SubObj;
: > : >   sub new {
: > : >     my $class = shift;
: > : >     return bless {}, $class;
: > : >   }
: > : >
: > : > I have a script with code like this:
: > : >
: > : >   $obj = Object->new();
: > : >   $sub = Object->SubObj();
: 
: How about:
: 
:         $sub = Object::SubObj();
: 
: Your sub 'SubObj' isn't a method, so you should call it as a function and
: not a method.

Well, except, in the effort to simplify all this, the $obj->SubObj()
method doesn't just pass in nothing.  It passes in various bits of
information contained in the Object-class object.  The sub SubObj
is more like:

  sub SubObj {
    my ( $this ) = @_;
    Object::SubObj->new( $this->{'var1'}, $this->{'var2'} );
  }

So it's actually tied pretty much to the POO interface.  I mean,
it's basically not /that/ big a deal, because by writing it:

  sub SubObj {
    my ( $this ) = @_;
    'Object::SubObj'->new( $this->{'var1'}, $this->{'var2'} );
  }

the whole problem is averted.  I'm really just wondering what
happens differently when the module is loaded from a startup.pl
script via PerlRequire (the PerlHandler is Apache::Registry) versus
when it's loaded as a result of a script call, because those
differences may cause other problems in the future.

* Philip Molter
* Data Foundry International
* http://www.datafoundry.net/
* [EMAIL PROTECTED]

Reply via email to