Don't ask to ask, just ask | |
PerlMonks |
Re: initializer method called from object constructor, overwriting the another object's variablesby Old_Gray_Bear (Bishop) |
on Oct 08, 2010 at 16:16 UTC ( [id://864233]=note: print w/replies, xml ) | Need Help?? |
The variables $self_ip and $partner_ip are "class variables" (defined in the package, but outside of one of the methods). Consequently they can be seen by all objects instantiated from the package. And as you found out, anything that can be seen by an object can be modified by the object.
If you need them to be part of each object, then they have to be defined in the object by adding them in the new()method --
---- OGB
In Section
Seekers of Perl Wisdom
|
|