Acme::Buffy - An encoding scheme for Buffy the Vampire Slayer fans


Acme-Buffy documentation Contained in the Acme-Buffy distribution.

Index


Code Index:

NAME

Top

Acme::Buffy - An encoding scheme for Buffy the Vampire Slayer fans

SYNOPSIS

Top

  use Acme::Buffy;

  print "Hello world";

DESCRIPTION

Top

The first time you run a program under use Acme::Buffy, the module removes most of the unsightly characters from your source file. The code continues to work exactly as it did before, but now it looks like this:

  use Acme::Buffy;
  BUffY bUFFY BUffY bUFFY bUfFy buffy BUFfy	buFFY BufFy	BufFY	bUFfy BuFFY buffy	bufFy bUffy bUffY BuFfy	BuffY	bUFfy BUfFY BUFFy	Buffy bUffY	
  BuFFY BUFFy	BufFy BUFfy BUfFY buFfy	BuffY	BuFfy	BUfFY bUffy	buFFy	BUffy	bUffy 

DIAGNOSTICS

Top

Can't buffy '%s'

Acme::Buffy could not access the source file to modify it.

Can't rebuffy '%s'

Acme::Buffy could not access the source file to execute it.

AUTHOR

Top

Leon Brocard <acme@astray.com>

This was based on Damian Conway's Bleach module and was inspired by an idea by Philip Newton. I blame London Perl Mongers too... http://www.mail-archive.com/london-pm%40lists.dircon.co.uk/msg03353.html

Yes, the namespace was named after me. Maybe.

COPYRIGHT

Top


Acme-Buffy documentation Contained in the Acme-Buffy distribution.

package Acme::Buffy;
use strict;
use warnings;
our $VERSION = '1.5';

my $horns = "BUffY bUFFY " x 2;
my $i     = 0;

sub _slay {
    my $willow = unpack "b*", pop;
    my @buffy = ( 'b', 'u', 'f', 'f', 'y', ' ' );
    my @BUFFY = ( 'B', 'U', 'F', 'F', 'Y', "\t" );
    my $demons = $horns;
    foreach ( split //, $willow ) {
        $demons .= $_ ? $BUFFY[$i] : $buffy[$i];
        $i++;
        $i = 0 if $i > 5;
    }
    return $demons;
}

sub _unslay {
    my $demons = pop;
    $demons =~ s/^$horns//g;
    my @willow;
    foreach ( split //, $demons ) {
        push @willow, /[buffy ]/ ? 0 : 1;
    }
    return pack "b*", join '', @willow;
}

sub _evil {
    return $_[0] =~ /\S/;
}

sub _punch {
    return $_[0] =~ /^$horns/;
}

sub import {
    open 0 or print "Can't rebuffy '$0'\n" and exit;
    ( my $demon = join "", <0> ) =~ s/.*^\s*use\s+Acme::Buffy\s*;\n//sm;
    local $SIG{__WARN__} = \&evil;
    do { eval _unslay $demon; exit }
        unless _evil $demon and not _punch $demon;
    open my $fh, ">$0" or print "Cannot buffy '$0'\n" and exit;
    print $fh "use Acme::Buffy;\n", _slay $demon and exit;
    print "use Acme::Buffy;\n", _slay $demon and exit;
    return;
}
"Grrr, arrrgh";

__END__