Help for this page

Select Code to Download


  1. or download this
    use Animal;
    use Cow;
    ...
    Cow->speak;
    Horse->speak;
    Sheep->speak;
    
  2. or download this
    package Animal;
    
    ...
    {
        die "'You have to define sound() in a subclass' found";
    }
    
  3. or download this
    package Cow;
    
    ...
    our @ISA = qw(Animal);
    
    sub sound { "moooo" }
    
  4. or download this
    package Sheep;
    
    ...
    our @ISA = qw(Animal);
    
    sub sound { "baaaah" }
    
  5. or download this
    package Horse;
    
    ...
    our @ISA = qw(Animal);
    
    sub sound { "neigh" }
    
  6. or download this
    a Cow goes moooo!
    a Horse goes neigh!
    a Sheep goes baaaah!