You shouldn't have $Dog::obj be a package global there. Make it a local variable in _init.
Your getColour, getName subroutines are returning the attributes of whatever hash reference is contained in $Dog::obj. This happens to point to the hash of whatever Dog was initialized most recently. They should return the attributes of their passed argument, @_[0], instead.
Perl packages do not work the same way as C++ classes.
Reputation Points: 1135
Solved Threads: 173
Super Senior Demiposter
Offline 2,479 posts
since Jun 2005