Hello,

I'm working on mod_perl project which has many different modules. One is
so-called 'main' modules which loads other when needed. Until now
everything worked just fine, but now one module just says that he doesn't
know the variable I've exported.

And interesting is, that when I comment out either
$sub_first->do_something(); or other three lines about Sub::Second then it
works just fine.

Error it get looks like this:

 Can't call method "notice" on an undefined value at
/usr/local/lib/perl/5.6.1/Sub/First.pm line 25.

First.pm and Second.pm use Export.pm exactly same way. So, it this some
mod_perl specific feature to just eat up some variables, or what?

Here are cut-down versions of my modules:

Site.pm:
-------------------------------------------------------------------------
package Site;

use strict;
use Apache::Log;

sub handler {
   my $r = shift;
   use vars qw( $log );
   $log = $r->log();

   if ( $some_case eq 'true' ) {
      use Sub::First qw( $log );
      my $sub_first = new Sub::First;

      $sub_first->do_something();

      if ( $some_other_case eq 'yes' ) {
         use Sub::Second qw( $log );
         my $sub_second = new Sub::Second;

# if I comment out $sub_first->do_something then it works...

         $sub_first->do_something();
         $sub_second->do_something_else();
      }
   }
}
1;

-----------------------------------------------------------
package Sub::First;

use strict;
use Apache::Log;

BEGIN {
   use Exporter();

   @Sub::First::ISA       = qw( Exporter );
   @Sub::First::EXPORT    = qw();
   @Sub::First::EXPORT_OK = qw( $log );

}

use vars qw( $log );

sub new {
   my $class = $_[0];
   my $objref = { };

   bless ( $objref, $class );
   return $objref;
}

sub do_somehing {
   $log->notice("Now this here doesn\'t work");
}

1;

----------------------------------------------------------

Rgds,
Viljo

Reply via email to