Created
July 2, 2012 08:46
-
-
Save ynonp/3032056 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v5.14; | |
package Zombie; | |
use Moose; | |
has 'victims', is => 'ro', isa => 'ArrayRef[Human]'; | |
has 'home', is => 'ro', isa => 'Str'; | |
sub eat_brain { | |
my $self = shift; | |
my @new_victims = @_; | |
push $self->victims, @new_victims; | |
} | |
package main; | |
my $z = Zombie->new; | |
for my $attr ( $z->meta->get_all_attributes ) { | |
say $attr->name; | |
} | |
for my $method ( $z->meta->get_all_methods ) { | |
say $method->fully_qualified_name; | |
} | |
if ( $z->meta->has_method( 'eat_brain' ) ) { | |
$z->eat_brain; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment