in reply to Package Name and Inheritance

The following is a fairly typical example of a simple constructor for the Stuff class:

package Stuff; sub new { my $class = shift; my %args = @_; bless { fooAttr => $args{foo}, barAttr => $args{bar}, }, $class; } 1;

If you bless the attribute hash into 'Stuff' rather than $class, a subclass of Stuff (say Junk) which calls the super-class's constructor will be blessed into the Stuff package instead of the Junk package.

If Junk adds/overrides any methods, they won't be called.

Another problem is that it's much harder to maintain a class if the classname is sprayed all over its constituent modules.

-David