line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Onebit; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 0.01; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub encode { |
6
|
0
|
|
|
0
|
|
0
|
my @bits = split //, shift; |
7
|
0
|
|
|
|
|
0
|
my $c = 0; |
8
|
0
|
|
|
|
|
0
|
my $buffer; |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
0
|
for $bit(@bits){ |
11
|
0
|
|
|
|
|
0
|
$bit = ord $bit; |
12
|
0
|
|
|
|
|
0
|
my $ch; |
13
|
0
|
0
|
|
|
|
0
|
if ($c > $bit){ |
|
|
0
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
$ch = '.' x ($bit+255-$c); |
15
|
|
|
|
|
|
|
}elsif($c < $bit){ |
16
|
0
|
|
|
|
|
0
|
$ch = '.' x ($bit-$c); |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
|
|
0
|
$ch .= ','; |
19
|
0
|
|
|
|
|
0
|
$buffer .= $ch; |
20
|
0
|
|
|
|
|
0
|
$c = $bit; |
21
|
|
|
|
|
|
|
} |
22
|
0
|
|
|
|
|
0
|
$buffer = join "\n", ($buffer =~ /(.{1,60})/g); |
23
|
0
|
|
|
|
|
0
|
$buffer; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
sub decode { |
26
|
1
|
|
|
1
|
|
4
|
my $c = 0; |
27
|
1
|
|
|
|
|
1
|
my $buffer; |
28
|
1
|
|
|
|
|
365
|
for my $b(split //, shift){ |
29
|
1848
|
100
|
|
|
|
2740
|
$c++ if $b eq '.'; |
30
|
1848
|
100
|
|
|
|
2553
|
$c = 0 if $c == 255; |
31
|
1848
|
100
|
|
|
|
2871
|
$buffer .= chr $c if $b eq ','; |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
245
|
$buffer; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
sub signed { |
36
|
1
|
|
|
1
|
|
10
|
$_[0] =~ /^[.,\n]+$/ |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
open 0 or print "Can't execute '$0'\n" and exit; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
(my $program = join "", <0>) =~ s/.*^\s*use\s+Acme::OneBit\s*;\n//sm; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
local $SIG{__WARN__} = \&garbled; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
do { |
46
|
|
|
|
|
|
|
eval decode $program; |
47
|
|
|
|
|
|
|
exit |
48
|
|
|
|
|
|
|
} if signed $program; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
open 0, ">$0" or print "Can't bit-ise '$0'\n" and exit; |
51
|
|
|
|
|
|
|
print {0} "use Acme::OneBit;\n", encode $program and exit; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |