Acme::Morse - Perl programming in morse code


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

Index


Code Index:

NAME

Top

Acme::Morse - Perl programming in morse code

SYNOPSIS

Top

	use Acme::Morse;

	print "S-O-S\n";

DESCRIPTION

Top

The first time you run a program under use Acme::Morse, the module converts your program to Morse code. The code continues to work exactly as it did before, but now it looks like this:

        use Acme::Morse;
	.--.-..--..---.-.--..--.-..--..---.-.--.
	.-.-........---..-..---.-..-.--..---.--.
	..-.---......-...-...-..--..-.-.-.--.-..
	----..-.-.--.-..--..-.-...---.-..---.--.
	.-...-..--.---...-.-....

DIAGNOSTICS

Top

Can't encode '%s'

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

Can't transmit '%s'

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

AUTHOR

Top

Damian Conway (as if you couldn't guess)

COPYRIGHT

Top


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

package Acme::Morse; $VERSION = 1.0;
my $signed = ".--.-..--..---.-.--."x2;
sub encypher { local $_ = unpack "b*", pop; tr/01/.-/; s/(.{40})/$1\n/g;
		$signed."\n".$_ }
sub decypher { local $_ = pop; s/^$signed|[^.-]//g; tr/.-/01/; pack "b*", $_ }
sub garbled { $_[0] =~ /\S/ }
sub signed { $_[0] =~ /^$signed/ }
open 0 or print "Can't transmit '$0'\n" and exit;
(my $telegram = join "", <0>) =~ s/.*^\s*use\s+Acme::Morse\s*;\n//sm;
local $SIG{__WARN__} = \&garbled;
do {eval decypher $telegram; print STDERR $@ if $@; exit}
	unless garbled $telegram && not signed $telegram;
open 0, ">$0" or print "Cannot encode '$0'\n" and exit;
print {0} "use Acme::Morse;\n", encypher $telegram and exit;
__END__