| 1 |
package Acme::Morsescip-perl cpan Acme-Bleach 1.15 Acme/Morse/; $VERSIONscip-perl cpan Acme-Bleach 1.15 Acme/Morse/$VERSION. = 1.0; |
| 2 |
my $signed = ".--.-..--..---.-.--."x2; |
| 3 |
sub encypherscip-perl cpan Acme-Bleach 1.15 Acme/Morse/encypher(). { local $_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/$_. = unpackscip-perl cpan Acme-Bleach 1.15 Acme/Morse/unpack(). "b*", popscip-perl cpan Acme-Bleach 1.15 Acme/Morse/pop().; tr/01/.-/; s/(.{40})/$1\n/g; |
| 4 |
$signed."\n".$_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/$_. } |
| 5 |
sub decypherscip-perl cpan Acme-Bleach 1.15 Acme/Morse/decypher(). { local $_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/$_. = popscip-perl cpan Acme-Bleach 1.15 Acme/Morse/pop().; s/^$signed|[^.-]//g; tr/.-/01/; packscip-perl cpan Acme-Bleach 1.15 Acme/Morse/pack(). "b*", $_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/$_. } |
| 6 |
sub garbledscip-perl cpan Acme-Bleach 1.15 Acme/Morse/garbled(). { $_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/`@_`.[0] =~ /\S/ } |
| 7 |
sub signedscip-perl cpan Acme-Bleach 1.15 Acme/Morse/signed(). { $_scip-perl cpan Acme-Bleach 1.15 Acme/Morse/`@_`.[0] =~ /^$signed/ } |
| 8 |
openscip-perl cpan Acme-Bleach 1.15 Acme/Morse/open(). 0 or printscip-perl cpan Acme-Bleach 1.15 Acme/Morse/print(). "Can't transmit '$0'\n" and exitscip-perl cpan Acme-Bleach 1.15 Acme/Morse/exit().; |
| 9 |
(my $telegram = joinscip-perl cpan Acme-Bleach 1.15 Acme/Morse/join(). "", <0>) =~ s/.*^\s*use\s+Acme::Morse\s*;\n//sm; |
| 10 |
local $SIGscip-perl cpan Acme-Bleach 1.15 Acme/Morse/`%SIG`.{__WARN__} = \&garbledscip-perl cpan Acme-Bleach 1.15 Acme/Morse/garbled().; |
| 11 |
do {eval decypherscip-perl cpan Acme-Bleach 1.15 Acme/Morse/decypher(). $telegram; print STDERR $@scip-perl cpan Acme-Bleach 1.15 Acme/Morse/`$@`. if $@scip-perl cpan Acme-Bleach 1.15 Acme/Morse/`$@`.; exitscip-perl cpan Acme-Bleach 1.15 Acme/Morse/exit().} |
| 12 |
unless garbledscip-perl cpan Acme-Bleach 1.15 Acme/Morse/garbled(). $telegram && not signedscip-perl cpan Acme-Bleach 1.15 Acme/Morse/signed(). $telegram; |
| 13 |
openscip-perl cpan Acme-Bleach 1.15 Acme/Morse/open(). 0, ">$0" or printscip-perl cpan Acme-Bleach 1.15 Acme/Morse/print(). "Cannot encode '$0'\n" and exitscip-perl cpan Acme-Bleach 1.15 Acme/Morse/exit().; |
| 14 |
printscip-perl cpan Acme-Bleach 1.15 Acme/Morse/print(). {0} "use Acme::Morse;\n", encypherscip-perl cpan Acme-Bleach 1.15 Acme/Morse/encypher(). $telegram and exitscip-perl cpan Acme-Bleach 1.15 Acme/Morse/exit().; |
| 15 |
__END__ |
| 16 |
=head1 NAME |
| 17 |
|
| 18 |
Acme::Morse - Perl programming in morse code |
| 19 |
|
| 20 |
=head1 SYNOPSIS |
| 21 |
|
| 22 |
use Acme::Morse; |
| 23 |
|
| 24 |
print "S-O-S\n"; |
| 25 |
|
| 26 |
=head1 DESCRIPTION |
| 27 |
|
| 28 |
The first time you run a program under C<use Acme::Morse>, the module converts |
| 29 |
your program to Morse code. The code continues to work exactly as it did |
| 30 |
before, but now it looks like this: |
| 31 |
|
| 32 |
use Acme::Morse; |
| 33 |
.--.-..--..---.-.--..--.-..--..---.-.--. |
| 34 |
.-.-........---..-..---.-..-.--..---.--. |
| 35 |
..-.---......-...-...-..--..-.-.-.--.-.. |
| 36 |
----..-.-.--.-..--..-.-...---.-..---.--. |
| 37 |
.-...-..--.---...-.-.... |
| 38 |
|
| 39 |
=head1 DIAGNOSTICS |
| 40 |
|
| 41 |
=over 4 |
| 42 |
|
| 43 |
=item C<Can't encode '%s'> |
| 44 |
|
| 45 |
Acme::Morse could not access the source file to modify it. |
| 46 |
|
| 47 |
=item C<Can't transmit '%s'> |
| 48 |
|
| 49 |
Acme::Morse could not access the source file to execute it. |
| 50 |
|
| 51 |
=back |
| 52 |
|
| •53 |
=over 4 |
| 54 |
|
| 55 |
=back |
| 56 |
|
| 57 |
=head1 AUTHOR |
| 58 |
|
| 59 |
Damian Conway (as if you couldn't guess) |
| 60 |
|
| 61 |
=head1 COPYRIGHT |
| 62 |
|
| 63 |
Copyright (c) 2001, Damian Conway. All Rights Reserved. |
| 64 |
This module is free software. It may be used, redistributed |
| 65 |
and/or modified under the terms of the Perl Artistic License |
| 66 |
(see http://www.perl.com/perl/misc/Artistic.html) |