sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:
Okay, my mind went blank, much too late last night (and not for bottled reasons). I coded what I intended to be a package with an inherited constructor, but the inherited routine was never called. The code looked like this: (Perl 5.10.0)
Edit: Typo in constructor-call removed.package Foo; use base qw/Bar/; sub new { my $class = shift; my $self = $class->SUPER::new(@_); bless $self, $class; return $self; } ... (in main) $bletch = Foo->new; print ref($bletch); # gives "Foo"
When I set croak calls and other things in the supposedly-inherited routine (in Foo), they never went off. But the routine in Bar did.
Furthermore: other methods defined in Foo (but not in Bar...) were available. So, it’s not like Perl didn’t know what package I was talking to ... it’s just that a routine defined in the child-class was ignored in favor of the parent, and I don’t know quite why.
Sure, I could define an initialize() method and call that from the constructor, but I want to understand what eluded my then-befuzzed brain.
Have I been this-quickly and so-utterly spoiled by Moose? :-)