File Coverage

blib/lib/Acme/Hodor.pm
Criterion Covered Total %
statement 7 12 58.3
branch n/a
condition n/a
subroutine 3 4 75.0
pod 0 4 0.0
total 10 20 50.0


line stmt bran cond sub pod time code
1             package Acme::Hodor; $VERSION = 1.00;
2             my $signed = "HODOR hodor hodor HODOR "x2;
3             sub encypher {
4 0     0 0 0 local $_ = unpack "b*", pop;
5 0         0 s/0/HODOR /g;
6 0         0 s/1/hodor /g;
7 0         0 s/(.{48})/$1\n/g;
8 0         0 $signed."\n".$_
9             }
10             sub decypher {
11 1     1 0 3 local $_ = pop;
12 1         301 s/^$signed|[^HODOR hodor ]//g;
13 1         33 s/HODOR /0/g;
14 1         20 s/hodor /1/g;
15 1         84 pack "b*", $_
16             }
17             sub garbled {
18 1     1 0 13 $_[0] =~ /\S/
19             }
20             sub signed {
21 1     1 0 23 $_[0] =~ /^$signed/
22             }
23             open 0 or print "Can't transmit '$0'\n" and exit;
24             (my $telegram = join "", <0>) =~ s/.*^\s*use\s+Acme::Hodor\s*;\n//sm;
25             local $SIG{__WARN__} = \&garbled;
26             do {eval decypher $telegram; print STDERR $@ if $@; exit}
27             unless garbled $telegram && not signed $telegram;
28             open 0, ">$0" or print "Cannot encode '$0'\n" and exit;
29             print {0} "use Acme::Hodor;\n", encypher $telegram and exit;
30             __END__