in reply to inheritance problems
Your real problem is that you are confused about what's going on in a Perl constructor. I would have written your constructor like so:
sub new_worker { my $class = shift; die "Use the copy constructor!\n" if ref $class; my $self = { name => "John Doe", age => 32, @_ , }; return bless $self, $class; }
You don't need any ref() crud in your constructor. That is cargo-cult programming and merlyn has posted enough diatribes about it, as have many other monks. If you want a copy-constructor, then create a clone() method. (You'll notice I don't allow this method to be a copy-constructor.)
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
|---|