File Coverage

blib/lib/Acme/Morse.pm
Criterion Covered Total %
statement 6 10 60.0
branch n/a
condition n/a
subroutine 3 4 75.0
pod 0 4 0.0
total 9 18 50.0


line stmt bran cond sub pod time code
1             package Acme::Morse; $VERSION = 1.0;
2             my $signed = ".--.-..--..---.-.--."x2;
3 0     0 0 0 sub encypher { local $_ = unpack "b*", pop; tr/01/.-/; s/(.{40})/$1\n/g;
  0         0  
  0         0  
4 0         0 $signed."\n".$_ }
5 1     1 0 2 sub decypher { local $_ = pop; s/^$signed|[^.-]//g; tr/.-/01/; pack "b*", $_ }
  1         97  
  1         5  
  1         4584  
6 1     1 0 4 sub garbled { $_[0] =~ /\S/ }
7 1     1 0 23 sub signed { $_[0] =~ /^$signed/ }
8             open 0 or print "Can't transmit '$0'\n" and exit;
9             (my $telegram = join "", <0>) =~ s/.*^\s*use\s+Acme::Morse\s*;\n//sm;
10             local $SIG{__WARN__} = \&garbled;
11             do {eval decypher $telegram; print STDERR $@ if $@; exit}
12             unless garbled $telegram && not signed $telegram;
13             open 0, ">$0" or print "Cannot encode '$0'\n" and exit;
14             print {0} "use Acme::Morse;\n", encypher $telegram and exit;
15             __END__