Acme::Cow - Talking barnyard animals (or ASCII art in general)
use Acme::Cow; $cow = new Acme::Cow; $cow->say("Moo!"); $cow->print(); $sheep = new Acme::Cow::Sheep; # Derived from Acme::Cow $sheep->wrap(20); $sheep->think(); $sheep->text("Yeah, but you're taking the universe out of context."); $sheep->print(\*STDERR); $duck = new Acme::Cow(File => "duck.cow"); $duck->fill(0); $duck->say(`figlet quack`); $duck->print($socket);
Acme::Cow is the logical evolution of the old cowsay program. Cows are derived from a base class (Acme::Cow) or from external files.
Cows can be made to say or think many things, optionally filling and justifying their text out to a given margin,
Cows are nothing without the ability to print them, or sling them as strings, or what not.
A list of key-value pairs. If you plan to use an external file as the template, you probably want to say:
$x = new Acme::Cow(File => 'file.cow');
A blessed reference to an Acme::Cow.
Acme::Cow
Specify (or retrieve) how far to the right (in spaces) the text balloon should be shoved.
(optional) A number.
The new value, if set; the existing value if not.
Specify (or retrieve) the column at which text inside the balloon should be wrapped. This number is relative to the balloon, not absolute screen position.
The number set here has no effect if you decline filling/adjusting of the balloon text.
Tell the cow to think its text instead of saying it.
(optional) Text to think.
None.
Tell the cow to say its text instead of thinking it.
(optional) Text to say.
Set (or retrieve) the text that the cow will say or think.
A list of lines of text (optionally terminated with newlines) to be displayed inside the balloon.
The new text, if set; the current text, if not.
Print a representation of the cow to the specified filehandle (STDOUT by default).
(optional) A filehandle.
Inform the cow to fill and adjust (or not) the text inside its balloon. By default, text inside the balloon is filled and adjusted.
(optional) A scalar; true if you want it to fill and adjust, false otherwise.
The current fill/adjust state, or the new one after setting.
Render the cow as a string.
(optional) A scalar that can be interpreted as a STRING type for Text::Template.
STRING
Text::Template
An ASCII rendering of your cow.
If you're using an external file for a cow template, any difficulties in processing the file will occur in this method.
Every time this method is called, the result is recalculated; there is no caching of results.
First, get comfortable with Text::Template and its capabilities.
{$balloon} is the text balloon; it should be on a line by itself, flush-left. {$tl} and {$tr} are what goes to the text balloon from the thinking/speaking part of the picture; {$tl} is a backslash ("\") for speech, while {$tr} is a slash ("/"); both are a lowercase letter O ("o") for thought. {$el} is a left eye, and {$er} is a right eye; both are "o" by default. Finally {$U} is a tongue, because a capital U looks like a tongue. (Its default value is "U ".) Escape all other curly-braces within the ASCII art with backslashes.
There are two methods to make your own cow file: the standalone file and the Perl module.
For the standalone file, take your piece of ASCII art and modify it according to the Text::Template rules above. Note that the balloon must be flush-left in the template if you choose this method. If the balloon isn't meant to be flush-left in the final output, use its over() method.
over()
For a Perl module, you should use Text::Template; and declare that your module ISA subclass of Acme::Cow. You may do other modifications to the variables in the template, if you wish. You will most likely need to write appropriate new() and as_string() methods; many examples are provided with the Acme::Cow distribution.
use Text::Template;
ISA
new()
as_string()
Put your module somewhere in your @INC path under the Acme::Cow:: tree, and use it like a normal Acme::Cow. Remember that you only inherit methods, not data; any data you want to pull out of Acme::Cow should be accessed explicitly. Other than that, make the methods work as expected and you should have a fully functional cow.
@INC
Acme::Cow::
They're called "cows" because the original piece of ASCII art was a cow. Since then, many have been contributed (i.e. the author has stolen some) but they're still all cows.
Tony Monroe <tmonroe plus perl at nog dot net>
perl, cowsay, figlet, fortune, cowpm
To install Acme::Cow, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::Cow
CPAN shell
perl -MCPAN -e shell install Acme::Cow
For more information on module installation, please visit the detailed CPAN module installation guide.