in reply to Re: Spiffy: How to define the constructor to take parameters
in thread Spiffy: How to define the constructor to take parameters

Thank you, Grandfather!

This solution works nicely.

Is there a way to use your solution but employing the "spiffy" call to $self->super instead of my $self = bless {}, $class; ?

This would enable to fill in another superclass in the future without having to adapt the constructor.

Thank you
Bernhard

Replies are listed 'Best First'.
Re^3: Spiffy: How to define the constructor to take parameters
by dragonchild (Archbishop) on Oct 29, 2007 at 01:36 UTC
    Did you try just my $self = super; instead of reflexively posting a question?

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Thank you, Dragonfly, I was not aware that super was a method that could be called as a free method. However, I could have seen it if more closely reading the docs.

      For the record, here's what I changed about the constructor:

      sub new() { my $raw = pop @_; my $self = super; $self->raw($raw); return $self; }
      Thank you
      Bernhard