#!/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 #
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mary.pl
by Blue (Hermit) on Dec 02, 2000 at 02:20 UTC | |
by maverick (Curate) on Dec 02, 2000 at 07:17 UTC | |
|
Re: mary.pl
by Yer Mom (Pilgrim) on Dec 01, 2000 at 15:43 UTC |