Rand Stats



Actions Status


Acme::Cow - Talking barnyard animals (or ASCII art in general)


  use Acme::Cow;

  my Acme::Cow $cow .= new;

  my $sheep = Acme::Cow::Sheep.new;    # Derived from Acme::Cow
  $sheep.text("Yeah, but you're taking the universe out of context.");

  my $duck = Acme::Cow.new(File => "duck.cow");
  $duck.say(`figlet quack`);


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.



my $cow = Acme::Cow.new(
  over => 0,    # optional
  wrap => 40,   # optional
  fill => True, # optional

  text => "hello world",  # specify the text of the cow
  File => "/foo/bar",     # specify when loading cow from a file

Create a new Acme::Cow object. Optionally takes the following named parameters:

has Str $.el is rw = 'o'; has Str $.er is rw = 'o'; has Str $.U is rw = ' ';


Specify (or retrieve) how far to the right (in spaces) the text balloon should be shoved.


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. Optionally takes the text to be thought.


Tell the cow to say its text instead of thinking it. Optionally takes the text to the said.


Set (or retrieve) the text that the cow will say or think.

Expects a list of lines of text (optionally terminated with newlines) to be displayed inside the balloon.


Print a representation of the cow to the specified filehandle ($*OUT by default).


Inform the cow to fill and adjust (or not) the text inside its balloon. By default, text inside the balloon is filled and adjusted.


Render the cow as a string.


{$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 ".)

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 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.

For a Perl module, declare that your module is a subclass of Acme::Cow. You may do other modifications to the variables in the template, if you wish: many examples are provided with the Acme::Cow distribution.


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.


perl, cowsay, figlet, fortune, cowpm


Elizabeth Mattijsen liz@raku.rocks


Original Perl version: Copyright 2002 Tony McEnroe, Raku adaptation: Copyright 2019, 2021 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.