Compare commits
8 Commits
cowsay-3.0
...
origin
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d66b866cf1 | ||
![]() |
2069267e70 | ||
![]() |
38fed456fa | ||
![]() |
df9da77a6c | ||
![]() |
b2e6dd28a9 | ||
![]() |
d6f7d8a3a7 | ||
![]() |
2556105c80 | ||
![]() |
5143a99c77 |
@@ -1,3 +1,8 @@
|
|||||||
|
3.03 28 May 1999
|
||||||
|
- Added cows/tux.cow, as suggested by xmanoel@i.am
|
||||||
|
- Compatibility with 5.6.0, due to a change in qw().
|
||||||
|
- Renamed devil.cow to daemon.cow, since I know better. :-)
|
||||||
|
|
||||||
3.02 04 November 1999
|
3.02 04 November 1999
|
||||||
- Fixed boneheaded code placement so that cowsay -l actually works.
|
- Fixed boneheaded code placement so that cowsay -l actually works.
|
||||||
|
|
||||||
@@ -23,4 +28,4 @@
|
|||||||
- SUBJECT is VERB OBJECT
|
- SUBJECT is VERB OBJECT
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
This file is part of cowsay. (c) 1999 Tony Monroe.
|
This file is part of cowsay. (c) 1999-2000 Tony Monroe.
|
||||||
|
@@ -3,6 +3,7 @@ INSTALL
|
|||||||
LICENSE
|
LICENSE
|
||||||
MANIFEST
|
MANIFEST
|
||||||
README
|
README
|
||||||
|
Wrap.pm.diff
|
||||||
install.sh
|
install.sh
|
||||||
pgp_public_key.txt
|
pgp_public_key.txt
|
||||||
cowsay
|
cowsay
|
||||||
@@ -14,8 +15,8 @@ cows/bud-frogs.cow
|
|||||||
cows/bunny.cow
|
cows/bunny.cow
|
||||||
cows/cheese.cow
|
cows/cheese.cow
|
||||||
cows/cower.cow
|
cows/cower.cow
|
||||||
|
cows/daemon.cow
|
||||||
cows/default.cow
|
cows/default.cow
|
||||||
cows/devil.cow
|
|
||||||
cows/dragon-and-cow.cow
|
cows/dragon-and-cow.cow
|
||||||
cows/dragon.cow
|
cows/dragon.cow
|
||||||
cows/elephant-in-snake.cow
|
cows/elephant-in-snake.cow
|
||||||
@@ -50,6 +51,7 @@ cows/telebears.cow
|
|||||||
cows/three-eyes.cow
|
cows/three-eyes.cow
|
||||||
cows/turkey.cow
|
cows/turkey.cow
|
||||||
cows/turtle.cow
|
cows/turtle.cow
|
||||||
|
cows/tux.cow
|
||||||
cows/udder.cow
|
cows/udder.cow
|
||||||
cows/vader-koala.cow
|
cows/vader-koala.cow
|
||||||
cows/www.cow
|
cows/www.cow
|
||||||
|
1
MANIFEST
1
MANIFEST
@@ -3,6 +3,7 @@ INSTALL Instructions for installing cowsay.
|
|||||||
LICENSE The license for use and redistribution of cowsay.
|
LICENSE The license for use and redistribution of cowsay.
|
||||||
MANIFEST This file.
|
MANIFEST This file.
|
||||||
README Read this first. Really.
|
README Read this first. Really.
|
||||||
|
Wrap.pm.diff Diff for Text/Wrap.pm.
|
||||||
cows/* Support files used by cowsay.
|
cows/* Support files used by cowsay.
|
||||||
cowsay Main cowsay executable.
|
cowsay Main cowsay executable.
|
||||||
cowsay.1 Main cowsay manual page.
|
cowsay.1 Main cowsay manual page.
|
||||||
|
2
Makefile
2
Makefile
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
FILES= Files.base
|
FILES= Files.base
|
||||||
PRODUCT= cowsay
|
PRODUCT= cowsay
|
||||||
VER= 3.02
|
VER= 3.03
|
||||||
BASE= ${PRODUCT}-${VER}
|
BASE= ${PRODUCT}-${VER}
|
||||||
TARZ= ${BASE}.tar.Z
|
TARZ= ${BASE}.tar.Z
|
||||||
TARGZ= ${BASE}.tar.gz
|
TARGZ= ${BASE}.tar.gz
|
||||||
|
12
README
12
README
@@ -1,5 +1,5 @@
|
|||||||
===========
|
===========
|
||||||
cowsay 3.02
|
cowsay 3.03
|
||||||
===========
|
===========
|
||||||
|
|
||||||
cowsay is a configurable talking cow, written in Perl. It operates
|
cowsay is a configurable talking cow, written in Perl. It operates
|
||||||
@@ -18,6 +18,16 @@ messages, multiple cowfiles, and even support for cows talking in
|
|||||||
figlet. The third version was a rewrite of the second into Perl
|
figlet. The third version was a rewrite of the second into Perl
|
||||||
5, whereupon the code got a lot smaller and more manageable. :-)
|
5, whereupon the code got a lot smaller and more manageable. :-)
|
||||||
|
|
||||||
|
If you are using Perl 5.004, you may have problems with Text::Wrap.
|
||||||
|
(Yeesh, this module changes more than it should...) I've included
|
||||||
|
a diff for the Text::Wrap (version 97.011701) that is shipped with
|
||||||
|
5.004_04; the concept is simple enough that even older Perls can
|
||||||
|
take advantage of this silly little patch; if there is a "sub fill"
|
||||||
|
in the documentation for the module, copy it to a more useful
|
||||||
|
section of that file. If not, just take "sub fill" wholesale from
|
||||||
|
the patch. Oh, and consider upgrading to 5.005_03 or later.
|
||||||
|
Please. You'll like it, I promise.
|
||||||
|
|
||||||
To install cowsay, consult the INSTALL file in this directory.
|
To install cowsay, consult the INSTALL file in this directory.
|
||||||
|
|
||||||
For the terms and conditions of use, consult the LICENSE file in
|
For the terms and conditions of use, consult the LICENSE file in
|
||||||
|
14
RELEASE
14
RELEASE
@@ -8,16 +8,18 @@ Steps to be done for release:
|
|||||||
|
|
||||||
(3) Change version number in cowsay.1.
|
(3) Change version number in cowsay.1.
|
||||||
|
|
||||||
(4) Package into tarballs and sign.
|
(4) CVS tag.
|
||||||
|
|
||||||
(5) Upload tarballs to FTP server.
|
(5) Package into tarballs and sign.
|
||||||
|
|
||||||
(6) Point LATEST.tar.gz to current version.
|
(6) Upload tarballs to FTP server.
|
||||||
|
|
||||||
(7) Modify cowsay web pages to reflect current version.
|
(7) Point LATEST.tar.gz to current version.
|
||||||
|
|
||||||
(8) Modify factoids with purl and miho to reflect current version.
|
(8) Modify cowsay web pages to reflect current version.
|
||||||
|
|
||||||
(9) Post to freshmeat.
|
(9) Modify factoids with purl and miho to reflect current version.
|
||||||
|
|
||||||
|
(10) Post to freshmeat.
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
47
Wrap.pm.diff
Normal file
47
Wrap.pm.diff
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
*** Wrap.pm.in Thu May 22 00:21:42 1997
|
||||||
|
--- Wrap.pm Fri Nov 12 10:00:15 1999
|
||||||
|
***************
|
||||||
|
*** 3,9 ****
|
||||||
|
require Exporter;
|
||||||
|
|
||||||
|
@ISA = (Exporter);
|
||||||
|
! @EXPORT = qw(wrap);
|
||||||
|
@EXPORT_OK = qw($columns);
|
||||||
|
|
||||||
|
$VERSION = 97.011701;
|
||||||
|
--- 3,9 ----
|
||||||
|
require Exporter;
|
||||||
|
|
||||||
|
@ISA = (Exporter);
|
||||||
|
! @EXPORT = qw(wrap fill);
|
||||||
|
@EXPORT_OK = qw($columns);
|
||||||
|
|
||||||
|
$VERSION = 97.011701;
|
||||||
|
***************
|
||||||
|
*** 66,71 ****
|
||||||
|
--- 66,90 ----
|
||||||
|
|
||||||
|
print "-----------$r---------\n" if $debug;;
|
||||||
|
return $r;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ## Copied up from below.
|
||||||
|
+ sub fill
|
||||||
|
+ {
|
||||||
|
+ my ($ip, $xp, @raw) = @_;
|
||||||
|
+ my @para;
|
||||||
|
+ my $pp;
|
||||||
|
+
|
||||||
|
+ for $pp (split(/\n\s+/, join("\n",@raw))) {
|
||||||
|
+ $pp =~ s/\s+/ /g;
|
||||||
|
+ my $x = wrap($ip, $xp, $pp);
|
||||||
|
+ push(@para, $x);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ # if paragraph_indent is the same as line_indent,
|
||||||
|
+ # separate paragraphs with blank lines
|
||||||
|
+
|
||||||
|
+ return join ($ip eq $xp ? "\n\n" : "\n", @para);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
36
cows/DragonAndCow.pm
Normal file
36
cows/DragonAndCow.pm
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package Acme::Cow::DragonAndCow;
|
||||||
|
use strict;
|
||||||
|
use Acme::Cow;
|
||||||
|
@Acme::Cow::DragonAndCow::ISA = qw(Acme::Cow);
|
||||||
|
my $dragon_and_cow = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tl} ^ /^
|
||||||
|
{$tl} / \ // \
|
||||||
|
{$tl} |\___/| / \// .\
|
||||||
|
{$tl} /O O \__ / // | \ \ *----*
|
||||||
|
/ / \/_/ // | \ \ \ |
|
||||||
|
@___@` \/_ // | \ \ \/\ \
|
||||||
|
0/0/| \/_ // | \ \ \ \
|
||||||
|
0/0/0/0/| \/// | \ \ | |
|
||||||
|
0/0/0/0/0/_|_ / ( // | \ _\ | /
|
||||||
|
0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
|
||||||
|
,-\} _ *-.|.-~-. .~ ~
|
||||||
|
\ \__/ `/\ / ~-. _ .-~ /
|
||||||
|
\____({$el}{$er}) *. \} \{ /
|
||||||
|
( (--) .----~-.\ \-` .~
|
||||||
|
//__\\ \__ Ack! ///.----..< \ _ -~
|
||||||
|
// \\ ///-._ _ _ _ _ _ _\{^ - - - - ~
|
||||||
|
EOC
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($dragon_and_cow);
|
||||||
|
}
|
149
cows/Example.pm
Normal file
149
cows/Example.pm
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
package Acme::Cow::Example;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use Acme::Cow;
|
||||||
|
|
||||||
|
@Acme::Cow::Example::ISA = qw(Acme::Cow);
|
||||||
|
|
||||||
|
my $generic_ascii_art = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tr}
|
||||||
|
{$el}{$er} {$tr}
|
||||||
|
___________________
|
||||||
|
/ Insert cute ASCII \
|
||||||
|
\ artwork here. /
|
||||||
|
-------------------
|
||||||
|
{$U}
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(24);
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($generic_ascii_art);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
__END__
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Acme::Cow::Example - How to write a "derived cow"
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
package Acme::Cow::MyCow;
|
||||||
|
use Acme::Cow;
|
||||||
|
@Acme::Cow::MyCow::ISA = qw(Acme::Cow);
|
||||||
|
|
||||||
|
my $my_cow = <<'EOC';
|
||||||
|
... template goes here ...
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new { ... }
|
||||||
|
|
||||||
|
sub as_string { ... }
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
First, put together your template as described in L<Acme::Cow>,
|
||||||
|
using L<Text::Template> as a reference. It is recommended that
|
||||||
|
you store this template in a variable in your package's namespace.
|
||||||
|
B<Your template should not have tab characters in it.> This will
|
||||||
|
cause ugly things to happen.
|
||||||
|
|
||||||
|
Your C<new> method will likely want to look a lot like this:
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assuming you stored the template as C<$my_cow> then
|
||||||
|
your C<as_string> method will likely want to be like this:
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($my_cow);
|
||||||
|
}
|
||||||
|
|
||||||
|
Below, we present the actual code in this module, so you can see
|
||||||
|
it in action. Yes, you can use this module to produce ASCII art.
|
||||||
|
No, it won't be very exciting.
|
||||||
|
|
||||||
|
=head1 Acme::Cow::Example code
|
||||||
|
|
||||||
|
package Acme::Cow::Example;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use Acme::Cow;
|
||||||
|
|
||||||
|
@Acme::Cow::Example::ISA = qw(Acme::Cow);
|
||||||
|
|
||||||
|
my $generic_ascii_art = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tr}
|
||||||
|
{$el}{$er} {$tr}
|
||||||
|
___________________
|
||||||
|
/ Insert cute ASCII \
|
||||||
|
\ artwork here. /
|
||||||
|
-------------------
|
||||||
|
{$U}
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(24);
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($generic_ascii_art);
|
||||||
|
}
|
||||||
|
|
||||||
|
=head1 HIGHLIGHTS
|
||||||
|
|
||||||
|
The C<{$balloon}> directive is flush left, but due to the call to
|
||||||
|
C<over()> in the C<new()> method, it will be shoved over 24 spaces
|
||||||
|
to the right, to line up with the thought/speech lines (represented
|
||||||
|
by C<{$tr}>).
|
||||||
|
|
||||||
|
=head1 SAVING WORK
|
||||||
|
|
||||||
|
Included with the C<Acme::Cow> distribution is a short program
|
||||||
|
called C<cowpm> which takes care of most of the boilerplate stuff
|
||||||
|
for you. It's almost as simple as I<just add ASCII art> but there's
|
||||||
|
still a bit that you have to fill in. It has its own documentation;
|
||||||
|
you should peruse L<cowpm>.
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
L<Acme::Cow>, L<cowpm>
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Tony Monroe <tmonroe plus perl at nog dot net>
|
||||||
|
|
||||||
|
=head1 BUGS
|
||||||
|
|
||||||
|
Very few.
|
35
cows/Frogs.pm
Normal file
35
cows/Frogs.pm
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package Acme::Cow::Frogs;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use Acme::Cow;
|
||||||
|
|
||||||
|
@Acme::Cow::Frogs::ISA = qw(Acme::Cow);
|
||||||
|
|
||||||
|
my $frogs = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tr}
|
||||||
|
{$tr}
|
||||||
|
oO)-. .-(Oo
|
||||||
|
/__ _\ /_ __\
|
||||||
|
\ \( | ()~() | )/ /
|
||||||
|
\__|\ | (-___-) | /|__/
|
||||||
|
' '--' ==`-'== '--' '
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(46);
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($frogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
40
cows/MechAndCow.pm
Normal file
40
cows/MechAndCow.pm
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package Acme::Cow::MechAndCow;
|
||||||
|
use strict;
|
||||||
|
use Acme::Cow;
|
||||||
|
@Acme::Cow::MechAndCow::ISA = qw(Acme::Cow);
|
||||||
|
my $mech_and_cow = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tl} ,-----.
|
||||||
|
{$tl} | |
|
||||||
|
{$tl} ,--| |-.
|
||||||
|
__,----| | | |
|
||||||
|
,;:: | `_____' |
|
||||||
|
`._______| i^i |
|
||||||
|
`----| |---'| .
|
||||||
|
,-------._| |== ||//
|
||||||
|
| |_|P`. /'/
|
||||||
|
`-------' 'Y Y/'/'
|
||||||
|
.==\ /_\
|
||||||
|
^__^ / /'| `i
|
||||||
|
({$el}{$er})\_______ /' / | |
|
||||||
|
(__)\ )\/\ /' / | `i
|
||||||
|
{$U} ||----w | ___,;`----'.___L_,-'`\__
|
||||||
|
|| || i_____;----\.____i""\____\
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(10);
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($mech_and_cow);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
38
cows/Stegosaurus.pm
Normal file
38
cows/Stegosaurus.pm
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package Acme::Cow::Stegosaurus;
|
||||||
|
use strict;
|
||||||
|
use Acme::Cow;
|
||||||
|
@Acme::Cow::Stegosaurus::ISA = qw(Acme::Cow);
|
||||||
|
my $stegosaurus = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tr} . .
|
||||||
|
{$tr} / `. .' "
|
||||||
|
{$tr} .---. < > < > .---.
|
||||||
|
| \ \ - ~ ~ - / / |
|
||||||
|
_____ ..-~ ~-..-~
|
||||||
|
| | \~~~\.' `./~~~/
|
||||||
|
--------- \__/ \__/
|
||||||
|
.' O \ / / \ "
|
||||||
|
(_____, `._.' | \} \/~~~/
|
||||||
|
`----. / \} | / \__/
|
||||||
|
`-. | / | / `. ,~~|
|
||||||
|
~-.__| /_ - ~ ^| /- _ `..-'
|
||||||
|
| / | / ~-. `-. _ _ _
|
||||||
|
|_____| |_____| ~ - . _ _ _ _ _>
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(20);
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($stegosaurus);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
207
cows/TextBalloon.pm
Normal file
207
cows/TextBalloon.pm
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
package Acme::Cow::TextBalloon;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $rcs_id = q$Id$;
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Acme::Cow::TextBalloon - A balloon of text
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use Acme::Cow::TextBalloon;
|
||||||
|
|
||||||
|
$x = new Acme::Cow::TextBalloon;
|
||||||
|
$x->add("bunch of text");
|
||||||
|
$x->wrapcolumn(29);
|
||||||
|
|
||||||
|
$y = new Acme::Cow::TextBalloon;
|
||||||
|
$y->adjust(0);
|
||||||
|
$y->add("more text");
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
C<Acme::Cow::TextBalloon> Creates and manipulates balloons of text,
|
||||||
|
optionally printing them. One may notice that the methods in this
|
||||||
|
module are named very similarly to those in C<Acme::Cow>; that's
|
||||||
|
because most of them have to do with the balloon rather than the
|
||||||
|
cow.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
use Text::Tabs;
|
||||||
|
use Text::Wrap;
|
||||||
|
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = {
|
||||||
|
fill => 1,
|
||||||
|
mode => 'say',
|
||||||
|
over => 0,
|
||||||
|
text => [ ],
|
||||||
|
wrap => 40,
|
||||||
|
};
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub wrapcolumn
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
if (@_) {
|
||||||
|
$self->{'wrap'} = $_[0];
|
||||||
|
}
|
||||||
|
return $self->{'wrap'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub mode
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->{'mode'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub think
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
$self->{'mode'} = "think";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub say
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
$self->{'mode'} = "say";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub print
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
$self->{'mode'} = "think";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub adjust
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
if (@_) {
|
||||||
|
$self->{'fill'} = $_[0];
|
||||||
|
}
|
||||||
|
return $self->{'fill'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub over
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
if (@_) {
|
||||||
|
$self->{'over'} = $_[0];
|
||||||
|
}
|
||||||
|
return $self->{'over'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_list
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->_construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return join('', $self->_construct());
|
||||||
|
}
|
||||||
|
|
||||||
|
sub add
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
push @{$self->{'text'}}, @_;
|
||||||
|
return $self->{'text'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub text
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
if (@_) {
|
||||||
|
my @l = @_;
|
||||||
|
$self->{'text'} = \@l;
|
||||||
|
}
|
||||||
|
return $self->{'text'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _maxlength
|
||||||
|
{
|
||||||
|
my ($len, $max);
|
||||||
|
$max = -1;
|
||||||
|
for my $i (@_) {
|
||||||
|
$len = length $i;
|
||||||
|
$max = $len if ($len > $max);
|
||||||
|
}
|
||||||
|
return $max;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _fill_text
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
for my $i (@{$self->{'text'}}) {
|
||||||
|
$i =~ s/\s+$//;
|
||||||
|
}
|
||||||
|
$Text::Tabs::tabstop = 8;
|
||||||
|
my @expanded = Text::Tabs::expand(@{$self->{'text'}});
|
||||||
|
unless ($self->{'fill'}) {
|
||||||
|
return @expanded;
|
||||||
|
}
|
||||||
|
$Text::Wrap::columns = $self->{'wrap'};
|
||||||
|
my @filled = split("\n", Text::Wrap::wrap("", "", @expanded));
|
||||||
|
$Text::Tabs::tabstop = 2; # Defeat a dumb heuristic.
|
||||||
|
my @final = expand(@filled);
|
||||||
|
return @final;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _construct
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $mode = $self->{'mode'};
|
||||||
|
my @message = $self->_fill_text();
|
||||||
|
my $max = _maxlength(@message);
|
||||||
|
my $max2 = $max + 2; ## border space fudge.
|
||||||
|
my @border; ## up-left, up-right, down-left, down-right, left, right
|
||||||
|
my @balloon_lines = ();
|
||||||
|
my $shove = " " x $self->{'over'};
|
||||||
|
my $format = "$shove%s %-${max}s %s\n";
|
||||||
|
if ($mode eq think) {
|
||||||
|
@border = qw[ ( ) ( ) ( ) ];
|
||||||
|
} elsif (@message < 2) {
|
||||||
|
@border = qw[ < > ];
|
||||||
|
} else {
|
||||||
|
@border = ( "/", "\\", "\\", "/", "|", "|" );
|
||||||
|
}
|
||||||
|
push(@balloon_lines,
|
||||||
|
"$shove " . ("_" x $max2) . "\n" ,
|
||||||
|
sprintf($format, $border[0], $message[0], $border[1]),
|
||||||
|
(@message < 2 ? "" :
|
||||||
|
map { sprintf($format, $border[4], $_, $border[5]) }
|
||||||
|
@message[1 .. $#message - 1]),
|
||||||
|
(@message < 2 ? "" :
|
||||||
|
sprintf($format, $border[2], $message[$#message], $border[3])),
|
||||||
|
"$shove " . ("-" x $max2) . "\n"
|
||||||
|
);
|
||||||
|
return @balloon_lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Tony Monroe E<lt>tmonroe+perl@nog.netE<gt>
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
L<Acme::Cow>
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
1;
|
||||||
|
__END__
|
43
cows/TuxStab.pm
Normal file
43
cows/TuxStab.pm
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package Acme::Cow::TuxStab;
|
||||||
|
use strict;
|
||||||
|
use Acme::Cow;
|
||||||
|
@Acme::Cow::TuxStab::ISA = qw(Acme::Cow);
|
||||||
|
my $tux_being_stabbed = <<'EOC';
|
||||||
|
{$balloon}
|
||||||
|
{$tl} , ,
|
||||||
|
{$tl} /( )`
|
||||||
|
{$tl} \ \___ / |
|
||||||
|
/- _ `-/ '
|
||||||
|
(/\/ \ \ /\
|
||||||
|
/ / | ` \
|
||||||
|
O O ) / |
|
||||||
|
`-^--'`< '
|
||||||
|
.--. (_.) _ ) /
|
||||||
|
|o_o | `.___/` /
|
||||||
|
|:_/ | `-----' /
|
||||||
|
//<- \ \----. __ / __ \
|
||||||
|
(| <- | )---|====O)))==) \) /====
|
||||||
|
/'\ <- _/`\---' `--' `.__,' \
|
||||||
|
\___)=(___/ | |
|
||||||
|
\ /
|
||||||
|
______( (_ / \______
|
||||||
|
,' ,-----' | \
|
||||||
|
`--\{__________) \/
|
||||||
|
EOC
|
||||||
|
|
||||||
|
sub new
|
||||||
|
{
|
||||||
|
my $proto = shift;
|
||||||
|
my $class = ref $proto || $proto;
|
||||||
|
my $self = $class->SUPER::new();
|
||||||
|
$self->over(8);
|
||||||
|
return bless $self, $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub as_string
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
return $self->SUPER::as_string($tux_being_stabbed);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
29
cows/blowfish.cow
Normal file
29
cows/blowfish.cow
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
##
|
||||||
|
## Blowfish
|
||||||
|
##
|
||||||
|
$the_cow = <<EOC;
|
||||||
|
$thoughts
|
||||||
|
$thoughts
|
||||||
|
| .
|
||||||
|
. |L /|
|
||||||
|
_ . |\\ _| \\--+._/| .
|
||||||
|
/ ||\\| Y J ) / |/| ./
|
||||||
|
J |)'( | ` F`.'/
|
||||||
|
-<| F __ .-<
|
||||||
|
| / .-'. `. /-. L___
|
||||||
|
J \\ < \\ | | O\\|.-'
|
||||||
|
_J \\ .- \\/ O | | \\ |F
|
||||||
|
'-F -<_. \\ .-' `-' L__
|
||||||
|
__J _ _. >-' )._. |-'
|
||||||
|
`-|.' /_. \\_| F
|
||||||
|
/.- . _.<
|
||||||
|
/' /.' .' `\\
|
||||||
|
/L /' |/ _.-'-\\
|
||||||
|
/'J ___.---'\\|
|
||||||
|
|\\ .--' V | `. `
|
||||||
|
|/`. `-. `._)
|
||||||
|
/ .-.\\
|
||||||
|
VK \\ ( `\\
|
||||||
|
`.\\
|
||||||
|
|
||||||
|
EOC
|
16
cows/tux.cow
Normal file
16
cows/tux.cow
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
##
|
||||||
|
## TuX
|
||||||
|
## (c) pborys@p-soft.silesia.linux.org.pl
|
||||||
|
##
|
||||||
|
$the_cow = <<EOC;
|
||||||
|
$thoughts
|
||||||
|
$thoughts
|
||||||
|
.--.
|
||||||
|
|o_o |
|
||||||
|
|:_/ |
|
||||||
|
// \\ \\
|
||||||
|
(| | )
|
||||||
|
/'\\_ _/`\\
|
||||||
|
\\___)=(___/
|
||||||
|
|
||||||
|
EOC
|
12
cowsay
12
cowsay
@@ -1,9 +1,9 @@
|
|||||||
#%BANGPERL%
|
#%BANGPERL%
|
||||||
|
|
||||||
##
|
##
|
||||||
## Cowsay 3.02
|
## Cowsay 3.03
|
||||||
##
|
##
|
||||||
## This file is part of cowsay. (c) 1999 Tony Monroe.
|
## This file is part of cowsay. (c) 1999-2000 Tony Monroe.
|
||||||
##
|
##
|
||||||
|
|
||||||
use Text::Tabs qw(expand);
|
use Text::Tabs qw(expand);
|
||||||
@@ -12,7 +12,7 @@ use File::Basename;
|
|||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
|
|
||||||
$version = "3.02";
|
$version = "3.03";
|
||||||
$progname = basename($0);
|
$progname = basename($0);
|
||||||
$eyes = "oo";
|
$eyes = "oo";
|
||||||
$tongue = " ";
|
$tongue = " ";
|
||||||
@@ -122,7 +122,11 @@ sub construct_balloon {
|
|||||||
@border = qw[ < > ];
|
@border = qw[ < > ];
|
||||||
} else {
|
} else {
|
||||||
$thoughts = '\\';
|
$thoughts = '\\';
|
||||||
@border = qw[ / \\ \\ / | | ];
|
if ($V and $V gt v5.6.0) { # Thanks, perldelta.
|
||||||
|
@border = qw[ / \\ \\ / | | ];
|
||||||
|
} else {
|
||||||
|
@border = qw[ / \ \ / | | ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
push(@balloon_lines,
|
push(@balloon_lines,
|
||||||
" " . ("_" x $max2) . " \n" ,
|
" " . ("_" x $max2) . " \n" ,
|
||||||
|
Reference in New Issue
Block a user