Not a Llama

Really did not have much to do before heading out to a show and was randomly looking at a few things and bumbled across this pic

moose_plus_llama_makes_____by_iceclanwolfwarrior-d39um8i.png


Then being inspired to look on CPAN I found this ACME::Llama so I just had to do this


package Acme::Moose;
use Moose;
has [ 'foodage','happiness','tired']=> (is=>'rw',default=>0,isa=>'Int',init_arg=>"");
sub feed {
	my $self = shift;
    $self->foodage($self->foodage()+1);
    if   ( $self->foodage() < 10 ) { 
    	$self->happiness($self->happiness+1) and return 1; 
    }
    else {
		$self->happiness($self->happiness()-1) and return; 
	}
}

sub play {
	my $self = shift;
    if ( $self->tired() == 1 ) {
        $self->happiness($self->happiness-5);
        return;
    }
    my $int = int( rand(20) );
    $self->happiness($self->happiness+2);
    if ( $int > 10 ) {
        $self->tired(1);
        return;
    }
    else {
       $self->tired(0);
       return 1;
    }
}

sub nap {
	my $self = shift;
    if ($self->tired == 0 ) { 
    	$self->happiness($self->happiness-1); 
    	return; 
    }
    else { 
    	$self->tired(0) and $self->happiness( $self->happiness()+1); 
    	return 1; 
    }
}

sub sacrifice {
    my ( $self) = shift;
    my ( $args ) = @_;
    $args->{'TO'} ||= '';
  
    if ( lc( $args->{'TO'} ) ne 'perl gods' ) {
        die('Who are you sacrificing this Moose to?');
    }
    if ( $self->happiness() > 10 ) {
        print(
"Congratulations. Your sacrifical Moose has appeased the Perl gods!\n"
        );
        exit;
    }
    else {
        die(
"Sorry, your Moose was not happy enough. Try to raise it better next time! :("
        );
    }
}

1;

Off to the show now so I will have to put it on CPAN tomorrow.

1 Comment

You forgot to s/Llama/Moose/ in a crucial place... Acme-Llama-0.01.

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations