in reply to Re: Inheritance - calling parent constructor
in thread Inheritance - calling parent constructor

Wrong syntax. That will attempt to call new in package SUPER. And you forgot to remove the bless that's now useless. See my reply to the OP for the correction.

Replies are listed 'Best First'.
Re^3: Inheritance - calling parent constructor
by bob_dobalina (Sexton) on Dec 29, 2009 at 19:13 UTC
    Wrong syntax. That will attempt to call new in package SUPER.

    - That's what I thought - i got the correct syntax from the link you had - thanks

    And you forgot to remove the bless that's now useless.

    - Could you elaborate here? I thought I have read that re-blessing is bad and was searching for best practices on re-blessing without much luck.

      I thought I have read that re-blessing is bad

      More accurately, it shouldn't be needed. If it's needed, it's a sign something else is wrong.

        But you only know whether something is wrong if you actually peek in the code of the parent class1. But that means breaking encapsulation2, which you aren't supposed to do when doing OO.

        I would leave in the bless. At worst, it's redundant. At best, it fixes something the parent does wrong.

        1 And keep peeking. If it's ok now, it may no longer be ok tomorrow after the sysadmin upgraded some packages.
        2 Of course, the code of the OP already assumes the parents constructor returns a hashref. So the OP has already sacrificed one the pearls of OO already.