in reply to Re: Composition Examples Sought
in thread Composition Examples Sought

/me has a bright light bulb floating above his head.
Ahaaa! Now I see what's going on here.

Thanks derby!!!

Replies are listed 'Best First'.
Re: Re: Re: Composition Examples Sought
by darrel3edndcom (Novice) on Jun 08, 2002 at 01:46 UTC
    This is what it looks like all together:
    #!/perl/bin/perl # package Person; sub new { my $class = shift; my $type = ref($class) || $class; my $self = {}; $self->{name} = shift; $self->{password} = shift; $self->{realname} = shift; bless $self, $type; } package Monk; sub new { my $class = shift; my $type = ref($class) || $class; my $self = {}; $self->{part1} = Person->new( @_ ); #One of the things things that +makes up a Monk is a Person $self->{level} = 0; bless $self, $type; } sub promote { my( $self ) = shift; print "Brother ", $self->{person}{name}, " is getting some XP\n"; $self->{level}++; } $monk1 = Monk::new("Monk","Darrel","mypass","Darrel Cusey"); print "Brother ", $monk1->{part1}{name}, " is level ", $monk1->{level} +,"\n"; promote($monk1); print "Brother ", $monk1->{part1}{name}, " is level ", $monk1->{level} +,"\n";;

    --
    I also like chicken.