perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nguyen Vu Hung <vu-h...@cnt.mxt.nes.nec.co.jp>
Subject Class inheritance, and SUPER under mod_perl2
Date Thu, 16 Aug 2007 00:57:33 GMT
Hello all,

I am quite new to Perl, mod_perl and mod_perl2 so please excuse me for
my questions. It my sounds noobish.

In the code below, the class XXX:YYY3 inherits Net::Cmd,
IO::Socket::Inet, create an object $obj with the SUPER keyword.

As far as I know, this code works well under Apache 1.3, Perl 5.6,
mod_perl 1.3.

But in current environment which consists Apache 2.0.52, Perl 5.8,
mod_perl 2.0.3, $obj becomes undefined (!!) after it is called with SUPER.

Anyone gets any clues?

Here is the code:

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

package XXX::YYY3;

@ISA = qw(Net::Cmd IO::Socket::INET);

sub new
{
my $self = shift;
my $type = ref($self) || $self;

my $hosts = "localhost";
my $obj;
my @localport = ();

my $h;
foreach $h (@{$hosts})
{
$obj = $type->SUPER::new(PeerAddr => ($h),
PeerPort => 110,
Proto => 'tcp',
LocalPort => 110,
Timeout => 120
) and last;
}


# obj is undefined now. why?
unless ( defined $obj ) {
$sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
APR::Const::SUCCESS, "XXX:: undef obj! ERROR. ");
}

# vuhung
# ref: http://www.perlmonks.org/?node_id=495975
return undef
unless defined $obj;

}


Mime
View raw message