Guest User

Untitled

a guest
Mar 8th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/usr/local/bin/perl
  2.  
  3. {
  4. package Animal;
  5. use Moose;
  6.  
  7. has extinct => ( isa => 'Bool', is => 'rw' );
  8.  
  9. no Moose;
  10. }
  11.  
  12. {
  13. package Cat;
  14. use Moose;
  15. extends 'Animal';
  16.  
  17. has breed => ( isa => 'Str', is => 'rw' );
  18.  
  19. sub legs { 4 }
  20. sub says { "miaow!" }
  21.  
  22. no Moose;
  23. }
  24.  
  25. {
  26. package Dog;
  27. use Moose;
  28. extends 'Animal';
  29.  
  30. has breed => ( isa => 'Str', is => 'rw' );
  31.  
  32. sub legs { 4 }
  33. sub says { "woof!" }
  34.  
  35. no Moose;
  36. }
  37.  
  38. {
  39. package Fish;
  40. use Moose;
  41. extends 'Animal';
  42.  
  43. has breed => ( isa => 'Str', is => 'rw' );
  44.  
  45. sub says { "gurgles!" }
  46.  
  47. no Moose;
  48. }
  49.  
  50. {
  51. package PetDog;
  52. use Moose;
  53. extends 'Dog';
  54.  
  55. has "name" => ( isa => 'Str', is => 'rw' );
  56.  
  57. no Moose;
  58. }
  59.  
  60.  
  61. my $dog = PetDog->new( breed => 'Dalmation', name => 'Spot' );
  62. print $dog->breed, "\n";
Add Comment
Please, Sign In to add comment