Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

It's a dog, but what kind? (polymorphism , in Perl OO)

by blue_cowdawg (Monsignor)
on Mar 23, 2004 at 19:22 UTC ( #339131=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package dog;
    
    ...
    }
    
    1;
    
  2. or download this
    package dog::cocker;
    use dog;
    ...
    }
    
    1;
    
  3. or download this
    use dog::cocker;
    
    my $sasha=new dog::cocker;
    
  4. or download this
    package dog; 
    
    ...
        print "Woof!\n";
    }
    1;
    
  5. or download this
    use dog;
    
    ...
    
    $sasha -> bark();
    
  6. or download this
    package dog::samoyed;
    use dog;
    ...
    
    
    1;
    
  7. or download this
    .
    .
    ...
    .
    .
    .
    
  8. or download this
    # after the "my $self" line we add:
         %def_attrs=(
    ...
           $self->{$key} = $def_attrs{$key} if not $self->{key};
         }
    
  9. or download this
    package dog::cattle_dog;
    use dog;
    ...
    }
    
    1;
    
  10. or download this
    package dog; 
    
    ...
       print "tail wagging\n";
    }
    1;
    
  11. or download this
    use dog;
    use Data::Dumper;
    ...
    $moose->bark; $moose->wag_tail;
    $cosette->bark; $cosette->wag_tail;
    $frosty->bark; $frosty->wag_tail;
    
  12. or download this
    $VAR1 = bless( {
                     'voice' => 'yarf',
    ...
    tail over back
    yarf
    tail wagging
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://339131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-12-22 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (113 votes), past polls