You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp> on 2007/08/16 04:15:12 UTC

Re: 答复: 答复: 答复: 答复: Class inheritance, and SUPER under mod_perl2

Lu,

I think IO::Socket:SSL has nothing to do here because this class
inherits Net::Cmd and IO::Socket::INET.

The next part of the code is to connect to a POP server and get emails,
therefore it has no relationship wih IO::Socket:SSL.

The point maybe the word SUPER. AFAIK, "SUPER" means "super class" in
Perl, right? Please fix me if I am wrong.
So, in this case,

$type->SUPER::new

refers to the parents clasess ( i.e, Net::Cmd, IO::Socket::INET ) of its
own ( XXX::YYY3 class ).

Do I need to post the code where XXX:YYY3 is being called?

Luke Lu ����ϕ����ޤ���:
> We can infer :
>    $obj = $type->SUPER::new(PeerAddr => ($h),
>   
>> PeerPort => 110,
>> Proto => 'tcp',
>> LocalPort => 110,
>> Timeout => 120
>> );# and last;
>>     
> This line may have some problems ,  you can use IO::Socket::SSL this package .
> Or you can give me the SUPER, I try to debug it.
> -----�ʼ�ԭ��-----
> ������: Nguyen Vu Hung [mailto:vu-hung@cnt.mxt.nes.nec.co.jp] 
> ����ʱ��: 2007��8��16�� 9:46
> �ռ���: Luke Lu
> ����: modperl@perl.apache.org
> ����: Re: ��: ��: ��: Class inheritance, and SUPER under mod_perl2
>
> Yes, it was undefined even inside foreach.
> You can see it above the debug lines on my code.
>
> Luke Lu ����ϕ����ޤ���:
>   
>> Hi,
>> the $obj is undefined  everytime?
>>
>> -----�ʼ�ԭ��-----
>> ������: Nguyen Vu Hung [mailto:vu-hung@cnt.mxt.nes.nec.co.jp] 
>> ����ʱ��: 2007��8��16�� 9:34
>> �ռ���: Luke Lu
>> ����: modperl@perl.apache.org
>> ����: Re: ��: ��: Class inheritance, and SUPER under mod_perl2
>>
>> Actually I did exactly what you told me yesterday and $obj was still
>> undefined.
>>
>> 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})
>> {
>> $obj = $type->SUPER::new(PeerAddr => ($h),
>> PeerPort => 110,
>> Proto => 'tcp',
>> LocalPort => 110,
>> Timeout => 120
>> );# and last;
>>
>> # obj is undefined now. so weird.
>> unless ( defined $obj ) {
>> $sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
>> APR::Const::SUCCESS, "XXX:: undef obj! ERROR. ");
>> }
>> last;
>> }
>> --------------------
>> Luke Lu ����ϕ����ޤ���:
>>   
>>     
>>> Ok, so sorry,
>>>  You only put the print "..." inside the foreach.
>>>  Please try it.
>>>
>>> -----�ʼ�ԭ��-----
>>> ������: Nguyen Vu Hung [mailto:vu-hung@cnt.mxt.nes.nec.co.jp] 
>>> ����ʱ��: 2007��8��16�� 9:24
>>> �ռ���: Luke Lu
>>> ����: modperl@perl.apache.org
>>> ����: Re: ��: Class inheritance, and SUPER under mod_perl2
>>>
>>> This code didn't run.
>>>
>>> I don't think we can put an "if" clause inside
>>>
>>> $type->SUPER::new(...)
>>>
>>> The error I got when running this code is:
>>>
>>>  syntax error at /XXX/YYY3.pm line 74, near "if"\nsyntax error at /XXX/YYY3.pm line 77, near "} else"\nsyntax error at /XXX/YYY3.pm line 82, near "
>>>
>>> Luke Lu ����ϕ����ޤ���:
>>>   
>>>     
>>>       
>>>> Hi,
>>>>   In this part:
>>>>     foreach $h (@{$hosts})
>>>>    {
>>>>       $obj = $type->SUPER::new(PeerAddr => ($h),
>>>>       PeerPort => 110,
>>>>       Proto => 'tcp',
>>>>       LocalPort => 110,
>>>>       Timeout => 120
>>>>    ) and last;
>>>>
>>>>   }
>>>> You can debug it like this 
>>>> foreach $h (@{$hosts})
>>>> {
>>>> $obj = $type->SUPER::new(PeerAddr => ($h),
>>>> PeerPort => 110,
>>>> Proto => 'tcp',
>>>> LocalPort => 110,
>>>> Timeout => 120
>>>>  If (defined ($obj))  {
>>>>    Print "ok";
>>>>  }
>>>> Else {
>>>>   Print "bad";
>>>> }
>>>> ) and last;
>>>> }
>>>>
>>>> According to this ,you can check it whether every time it will be 'ok' or not.
>>>> If the last time is output 'bad', then you can find the real reason
>>>>
>>>> If still have any question,please contact with me/
>>>>
>>>> luke
>>>>
>>>> -----�ʼ�ԭ��-----
>>>> ������: Nguyen Vu Hung [mailto:vu-hung@cnt.mxt.nes.nec.co.jp] 
>>>> ����ʱ��: 2007��8��16�� 8:58
>>>> �ռ���: modperl@perl.apache.org
>>>> ����: Class inheritance, and SUPER under mod_perl2
>>>>
>>>> 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;
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>   
>>>>     
>>>>       
>>>>         
>>>   
>>>     
>>>       
>>
>>   
>>     
>
>
>
>