#!/usr/local/bin/perl -w
package Mary;
$lamb = new Sheep (size => 'little');
$lamb->fleece("#FFFFFF");
sub go {
my $self = shift;
$location = shift;
$lamb->go($location);
}
Mary->go('school');
package Sheep;
sub new {
my $class = shift; bless { @_ }, $class;
}
sub fleece {
my $sheep = shift; $sheep->{fleece} = shift;
}
sub go {
my $sheep = shift;
$sheep->{location} = shift;
if ($sheep->{location} =~ /school/i) {
warn "Sheep are not allowed at school.\n";
Children->see($sheep, $sheep->{location});
}
}
package Children;
sub see {
my $children = shift;
my($object, $location) = @_;
if ($object->isa('Sheep') and $location =~ /school/i) {
$children->laugh();
$children->play();
}
}
sub laugh {
print "Hahaha!\n";
}
sub play {
print "Whee!\n";
}
#
# Mary had a little lamb
# Its fleece was white as snow
# And everywhere that Mary went
# The lamb was sure to go
#
# It followed her to school one day
# Which was against the rules
# It made the children laugh and play
# To see a lamb at school
#
In reply to mary.pl
by chipmunk