Joe Schaefer ????????:
Nguyen Vu Hung <[EMAIL PROTECTED]> writes:

Here is the code ( check if $obj is undefined inside foreach )

------------
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})

Are you using symrefs or something?
It seems that I am using symref. Please see the cose below ( more original - The code I have posted in the previous emails are slight modified, by me, so it may contains errors! )
 $hosts here is
a scalar, not an arrayref.
Yes, I changed my code. Please see below.
 Are you sure the loop
is being entered at all?

Yes, because the log inisde the foreach loop was printed out.

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 $host = shift if @_ % 2;
my %arg = @_;
my $hosts = defined $host ? [ $host ] : $NetConfig{pop3_hosts};
my $obj;
my @localport = exists $arg{ResvPort} ? ( LocalPort => $arg{ResvPort} ): ();

my $h;
foreach $h (@{$hosts})
{

$obj = $type->SUPER::new(PeerAddr => ($host = $h),
PeerPort => 110, #$arg{PeerPort} || 110,#(110)',
Proto => 'tcp',
LocalPort => 110,
Timeout => 120 #defined $arg{Timeout}

);# and last; #last:??????

# printed:undef -> i.e, $obj is undefined at this moment.
unless ( defined $obj ) {
$sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
APR::Const::SUCCESS, "xpop3:: undef obj! ERROR. ");
}

last;
}
}

# printed:undef -> i.e, $obj is undefined at this moment.
unless ( defined $obj ) {
$sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
APR::Const::SUCCESS, "xpop3:: undef obj! ERROR. ");
}

Reply via email to