nysus has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl my @pasture; my $animal; @pasture = qw(Cow Cow Horse Sheep Sheep Cow); foreach $animal (@pasture) { $animal->speak; } { package Cow; @ISA = qw(Animal); sub sound { "moooo" } } { package Horse; sub sound { "neigh" } sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n"; } } { package Sheep; sub sound { "baaaaaaaa" } sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n"; } } { package Animal; sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n" } }
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar";
$nysus = $PM . $MCF;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: @ISA doesn't seem to work
by tye (Sage) on Jun 05, 2001 at 16:31 UTC |