The answer to the trick question is that the subroutine name in package
Sub::First is misspelled (missing a "t").

However, I think I would provide the Apache::Log object as a parameter to
new() rather than twiddling with package vars to try to have it magically
updated by Exporter.  For example:

package Sub::First;
use strict;

# simple constructor expects classname, log object
sub new {
    my($class,$ap_log) = @_;
    return bless {apache_log=>$ap_log}, $class;
}

sub do_something {
    $self->{apache_log}->notice("this will work");
}

package Sub::Second;
use strict;

# another simple constructor expects classname, log object
sub new {
    my($class,$ap_log) = @_;
    return bless {apache_log=>$ap_log}, $class;
}

sub do_something_else {
    $self->{apache_log}->notice("this will work, too");
}

package Site;
use strict;
use Sub::First;
use Sub::Second;

sub handler {
   my $r = shift;

   # test values for conditions
   my $some_case = 'true';
   my $some_other_case = 'yes';

   if ( $some_case eq 'true' ) {
      my $sub_first = Sub::First->new($r->log);

      $sub_first->do_something();

      if ( $some_other_case eq 'yes' ) {
         my $sub_second = Sub::Second->new($r->log);
         $sub_first->do_something();
         $sub_second->do_something_else();
      }
   }
}
# End Example


Regards,

Tim Tompkins
----------------------------------------------
Programmer
http://www.arttoday.com/
http://www.rebelartist.com/
----------------------------------------------

Reply via email to