--- "Jos I. Boumans" <[EMAIL PROTECTED]> wrote:
> just print out $self
> it will tell you what it is
> 
> -Jos
> >     Is the new_bp_handler_config_t(@args) a new array reference or a new
> hash ??
> >
> >
> >
> > sub new {
> >       my $self = shift;
> >       my @args = @_;
> >       $self = Netc::new_bp_handler_config_t(@args);
> >       return undef if (!defined($self));

Tom,

Actually, I suspect that printing out $self may be misleading in this case.  It looks 
like we have
an object constructor that may inherit from Netc (though I see problems with it, more 
on that in a
bit).  To see what $self is, you can use Data::Dumper;

    $self = Netc::new_bp_handler_config_t(@args);
    use Data::Dumper;
    print Dumper $self;

That will tell you what $self contains.  It's probably a hashref or an arrayref that's 
been
blessed into a class that is named as the first argument in @args.  The above code 
snippet appears
to be improperly subclassing Netc (I have no idea what Netc is).  You can see that the 
first line
is assigning a value to $self and the third line is overwriting it, so this definitely 
appears
problematic.

I suspect that the first element in @args is not going to be a class name.  But if
Netc::new_bp_handler_config_t is an object constructor, it's going to expect one.  If 
it is a
constructor, someone may be hardcoding the classname into the @args array.  The 
problem with that
is then, if the classname should change, all code that calls the 'new' constructor 
constructor
needs to be updated.

If you're having problems with the above code, it may because the first argument in 
@args is
*improperly* being considered a classname by Netc::new_bp_handler_config_t.  The 
effects are
unpredictable and you can check that by printing "Dumper $self" and checking to see if 
the
classname (again, assuming it's a constructor) is data that needs to be preserved.  If 
that is
occurring, the following may fix the code:

    my $class = shift;
    my @args = @_;
    $self = Netc::new_bp_handler_config_t($class, @args);
    return undef if (!defined($self));

Cheers,
Curtis poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to