Acme-Labs
view release on metacpan or search on metacpan
lib/Acme/Labs.pm view on Meta::CPAN
package Acme::Labs;
our $VERSION = '1.1'; # September 14, 2005
srand; rand($.) < 1 && (our $but = $_) while <DATA>; chomp $but; # randomly choose a line of DATA
our $Qyes; our $yEs="I think so, Brain";
our $pondering = qq(BRAIN:\t"Pinky, are you pondering what I'm pondering?"\nPINKY:\t"$yEs, $but"\n\n);
my @interjections=qw(NARF POIT ZORT EGAD);
my $interjections=join("|", @interjections); # OR'd list for regexes
our (%zord, %chroz);
my $c=ord("A"); foreach my $w (@interjections) {my $l=length $w; for(my $n=0; $n<2**$l; $n++) {my $narf; my $b=unpack("b$l", chr $n); for my $i (0..$l-1) { $narf.=substr($b, $i, 1)?lc substr($w, $i, 1):uc substr($w, $i, 1); } $chroz{$narf}=chr($c); $...
#----------------------------------------------------------------------
sub AYPWIP
{
local $pondering="\Q$pondering\E";
local $yEs="\Q$yEs\E";
local $Qyes="\Q$yEs\E";
$pondering=~s[$Qyes.*\s*][$yEs]s;
$_[0] =~ /^\s*$pondering/
}
sub pinking
{
local $_=pop;
s/([A-Z])/ $zord{$1}/ig;
"\n\n$pondering$_"
}
sub brainier
{
local $_ = pop;
local $pondering="\Q$pondering\E";
local $yEs="\Q$yEs\E";
local $Qyes="\Q$yEs\E";
$pondering=~s[$Qyes.*][$yEs]s;
s/^\s*$pondering.*\n\n//;
s/^\n//;
s/ ($interjections)/$chroz{$1}/ig;
$_
}
#----------------------------------------------------------------------
open 0 or print "NARF? What does that mean?!? '$0'\n" and exit; # read our source code
(my $plan = join "", <0>) =~ s[(.*^\s*use\s+Acme::Labs\s*;)]["\n" x (split /\n/, $1)]mes; # capture intro for preserving later on (and leave behind the same number of \n's so we don't throw off the line numbers)
do {eval brainier $plan or print STDERR $@; exit} if AYPWIP($plan); # if we recognise a Pinky's Plan, apply to North Pole, I mean, Brain
open 0, ">$0" or print "Cannot get pinking shears! '$0'\n" and exit; # Otherwise, prepare to pinkify!
print {0} $1, pinking $plan # write out reformulated plan
and print STDOUT "Fun-fun-silly-willy!\n"
and do {eval brainier $plan or print STDERR $@; exit}; # and execute our plan
#----------------------------------------------------------------------
=pod
=head1 NAME
Acme::Labs -- When you need an extraordinary plan to Take Over the World
=head1 SYNOPSIS
( run in 2.227 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )