Acme-Machi
view release on metacpan or search on metacpan
lib/Acme/Machi.pm view on Meta::CPAN
Return: how many words have she/he learnt.
=cut
sub learning {
(ref $_[0]) || croak "Oops! Cannot use class method setting the object!";
unshift (@{$_[0]{Words}}, @_[1 .. $#_]);
}
=head2 affectionate
Randomly output one of predefined words to FILE_HANDLE, which default of is STDOUT.
Return: 1 if no problems while calling this method.
=cut
sub affectionate {
(ref $_[0]) || croak "Oops! Cannot call affectionate() using class method!";
my $words_list = $_[0]{Words};
($_[1] // *STDOUT)->print( $_[0]->name(),": ", $words_list->[int(rand($#$words_list))], "\n");
}
( run in 0.475 second using v1.01-cache-2.11-cpan-0a6323c29d9 )