Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Creating Common Constructor

by jaa (Friar)
on Jul 10, 2003 at 15:16 UTC ( [id://273010]=note: print w/replies, xml ) Need Help??


in reply to Creating Common Constructor

Maybe something like:

#---------------------------------------- package Zoo::Animal; use strict; 1; sub new { my $class = shift; my $sref_oid = Zoo::Zoo->_gen_oid(); my $self = { _oid => $$sref_oid, @_ }; bless $self, $class; print "Animal initialised\n"; return $self; } #---------------------------------------- package Zoo::Camel; use strict; use base qw( Zoo::Animal ); sub new { my ( $class ) = @_; my $self = $class->SUPER::new( _type => 'camel', _color => 'grey', _legs => 4, _humps => 2, ); print "Camel initialised\n"; return $self; } #---------------------------------------- package Zoo::Lama; use strict; use base qw( Zoo::Animal ); sub new { my ( $class ) = @_; my $self = $class->SUPER::new( _type => 'lama', _color => 'white', _legs => 4, ); print "Lama initialised\n"; return $self; }
I don't know if I agree with your Zoo::Zoo 8-)
package Zoo::Zoo; use UUID; use lib '.'; use base qw( Zoo::Animal Zoo::Camel Zoo::Lama );
This seems to say to me that a Zoo::Zoo is an Animal, a Camel or a Lama - I would have thought the Zoo is more like a container of Animals, rather than an actual beastie?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://273010]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-18 04:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found