File Coverage

blib/lib/Acme/DotDotGone.pm
Criterion Covered Total %
statement 19 40 47.5
branch 7 18 38.8
condition 0 6 0.0
subroutine 6 9 66.6
pod n/a
total 32 73 43.8


line stmt bran cond sub pod time code
1             package Acme::DotDotGone;
2              
3 1     1   13905 use 5.006;
  1         3  
4 1     1   5 use strict;
  1         2  
  1         17  
5 1     1   4 use warnings;
  1         9  
  1         174  
6              
7             =head1 NAME
8              
9             Acme::DotDotGone - The great new Acme::DotDotGone!
10              
11             =head1 VERSION
12              
13             Version 0.01
14              
15             =cut
16              
17             our $VERSION = '0.01';
18              
19             our %dots;
20             BEGIN {
21             %dots = (
22             toDots => sub {
23 0         0 join ' ', map { $dots{$_}() } split '', unpack "b*", shift;
  0         0  
24             },
25             fromDots => sub {
26 0         0 pack "b*", join '', map { $dots{$_}() } split ' ', shift;
  0         0  
27             },
28 0         0 '.' => sub { 0 },
29 0         0 '..' => sub { 1 },
30 0         0 0 => sub { '.' },
31 0         0 1 => sub { '..' },
32 0         0 stderr => sub { print @_ }
33 1     1   13 );
34 1         374 close STDERR; # *\o/*
35             }
36              
37             sub import {
38 1 50 0 1   42 open FH, "<$0" or print "Cannot read '$0'\n" and exit;
39              
40 1 50       8 my $reg = $_[1]
41             ? qr/(.*)\1^\s*use\s+Acme::DotDotGone\s+($_[1]);\n/
42             : qr/.*^\s*use\s+Acme::DotDotGone;\n/;
43              
44 1         19 ($_[2] = (join '', )) =~ s/$reg//sm;
45 1 50       6 $_[2] = $1 . $_[2] if $1;
46              
47 1         6 close FH;
48              
49             ($_[2], $_[3], $_[4]) = (($2)
50             ? ($2 eq 'dot')
51             ? sub {
52 0     0   0 $_[1] = $dots{toDots}($_[0]);
53 0         0 $_[0], $_[1], $_[1];
54             }
55             : sub {
56 0     0   0 $_[1] = $dots{fromDots}($_[0]);
57 0         0 $_[1], $_[0], $_[1];
58             }
59             : ($_[2] =~ m/[a-zA-Z]/)
60             ? sub {
61             undef
62 1     1   4 }
63             : sub {
64 0     0   0 $_[1] = $dots{fromDots}($_[0]);
65 0         0 $_[1], $_[0];
66             }
67 1 0       10 )->($_[2]);
    50          
    50          
68              
69 1 50       4 if ($_[4]) {
70 0 0 0     0 open FH, ">$0" or print "Cannot encode. '$0'\n" and exit;
71 0         0 print FH "use Acme::DotDotGone;\n";
72 0         0 print FH $_[4];
73 0         0 close FH;
74             }
75              
76 1 50       13 do { eval "$_[2]"; $dots{stderr}($@); } if $_[2];
  0            
  0            
77             }
78              
79             =head1 SYNOPSIS
80              
81             Quick summary of what the module does.
82              
83             Perhaps a little code snippet.
84              
85             vim worldEnding.pl
86              
87             use Acme::DotDotGone dot;
88              
89             use feature 'say';
90             say 'The world is about to end';
91              
92             1;
93              
94             perl worldEnding.pl
95              
96             The world is about to end
97              
98             cat worldEnding.pl
99              
100             use Acme::DotDotGone;
101             . .. . .. . . . . .. . .. . .. .. .. . .. .. . . .. .. .. . .. . .. . . .. .. . . . . . . .. . . . .. .. . . .. .. . .. . .. . . .. .. . .. . . . . .. .. . . . .. . .. .. .. . .. . .. . .. .. .. . . .. . . .. .. .. . .. . .. . . .. .. . . . . . . .. . . .. .. .. . . .. . . .. .. . . .. .. .. . .. . . . . .. .. . .. . . .. .. .. .. . .. .. .. . . .. . . .. .. . .. .. .. . . . .. . .. . . . . .. .. . . .. .. .. . .. . . . . .. .. . .. . . .. .. .. .. . . . . . . .. . . .. .. .. . . .. . . . . .. . .. . .. . . . . .. . .. .. . .. . .. . . .. .. . . . . . . .. . . .. .. .. . .. .. .. . .. .. .. .. . .. .. . . .. . . .. .. .. . . . .. .. . .. .. . . . .. . . .. .. . . . . . . .. . . .. . . .. . .. .. . .. .. . . .. .. .. . . . . . . .. . . .. . . . . .. .. . . .. . . . .. .. . .. .. .. .. . .. .. . .. . .. . .. .. .. . . . .. . .. .. .. . . . . . . .. . . . . .. . .. .. .. . .. .. .. .. . .. .. . . . . . . .. . . .. . .. . . .. .. . . .. .. .. . .. .. . . . .. . . .. .. . .. .. .. . . .. . . .. .. . .. .. .. . . . .. . .. . . . . . .. . .. . . . . .. . . . .. .. . . .. .. . .. .. .. . . . .. . .. . . . .
102              
103             perl worldEnding.pl
104              
105             The World is about to end
106              
107             vim worldEnding.pl
108            
109             use Acme::DotDotGone panic;
110             . .. . .. . . . . .. . .. . .. .. .. . .. .. . . .. .. .. . .. . .. . . .. .. . . . . . . .. . . . .. .. . . .. .. . .. . .. . . .. .. . .. . . . . .. .. . . . .. . .. .. .. . .. . .. . .. .. .. . . .. . . .. .. .. . .. . .. . . .. .. . . . . . . .. . . .. .. .. . . .. . . .. .. . . .. .. .. . .. . . . . .. .. . .. . . .. .. .. .. . .. .. .. . . .. . . .. .. . .. .. .. . . . .. . .. . . . . .. .. . . .. .. .. . .. . . . . .. .. . .. . . .. .. .. .. . . . . . . .. . . .. .. .. . . .. . . . . .. . .. . .. . . . . .. . .. .. . .. . .. . . .. .. . . . . . . .. . . .. .. .. . .. .. .. . .. .. .. .. . .. .. . . .. . . .. .. .. . . . .. .. . .. .. . . . .. . . .. .. . . . . . . .. . . .. . . .. . .. .. . .. .. . . .. .. .. . . . . . . .. . . .. . . . . .. .. . . .. . . . .. .. . .. .. .. .. . .. .. . .. . .. . .. .. .. . . . .. . .. .. .. . . . . . . .. . . . . .. . .. .. .. . .. .. .. .. . .. .. . . . . . . .. . . .. . .. . . .. .. . . .. .. .. . .. .. . . . .. . . .. .. . .. .. .. . . .. . . .. .. . .. .. .. . . . .. . .. . . . . . .. . .. . . . . .. . . . .. .. . . .. .. . .. .. .. . . . .. . .. . . . .
111              
112             perl worldEnding.pl
113              
114             The World is about to end
115              
116             less worldEnding.pl
117              
118             use Acme::DotDotGone;
119              
120             use feature 'say';
121             say 'The world is about to end';
122              
123             1
124              
125             =head1 AUTHOR
126              
127             Robert Acock, C<< >>
128              
129             =head1 BUGS
130              
131             Please report any bugs or feature requests to C, or through
132             the web interface at L. I will be notified, and then you'll
133             automatically be notified of progress on your bug as I make changes.
134              
135             =head1 SUPPORT
136              
137             You can find documentation for this module with the perldoc command.
138              
139             perldoc Acme::DotDotGone
140              
141              
142             You can also look for information at:
143              
144             =over 4
145              
146             =item * RT: CPAN's request tracker (report bugs here)
147              
148             L
149              
150             =item * AnnoCPAN: Annotated CPAN documentation
151              
152             L
153              
154             =item * CPAN Ratings
155              
156             L
157              
158             =item * Search CPAN
159              
160             L
161              
162             =back
163              
164              
165             =head1 ACKNOWLEDGEMENTS
166              
167              
168             =head1 LICENSE AND COPYRIGHT
169              
170             Copyright 2017 Robert Acock.
171              
172             This program is free software; you can redistribute it and/or modify it
173             under the terms of the the Artistic License (2.0). You may obtain a
174             copy of the full license at:
175              
176             L
177              
178             Any use, modification, and distribution of the Standard or Modified
179             Versions is governed by this Artistic License. By using, modifying or
180             distributing the Package, you accept this license. Do not use, modify,
181             or distribute the Package, if you do not accept this license.
182              
183             If your Modified Version has been derived from a Modified Version made
184             by someone other than you, you are nevertheless required to ensure that
185             your Modified Version complies with the requirements of this license.
186              
187             This license does not grant you the right to use any trademark, service
188             mark, tradename, or logo of the Copyright Holder.
189              
190             This license includes the non-exclusive, worldwide, free-of-charge
191             patent license to make, have made, use, offer to sell, sell, import and
192             otherwise transfer the Package with respect to any patent claims
193             licensable by the Copyright Holder that are necessarily infringed by the
194             Package. If you institute patent litigation (including a cross-claim or
195             counterclaim) against any party alleging that the Package constitutes
196             direct or contributory patent infringement, then this Artistic License
197             to you shall terminate on the date that such litigation is filed.
198              
199             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
200             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
201             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
202             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
203             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
204             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
205             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
206             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207              
208              
209             =cut
210              
211             1; # End of Acme::DotDotGone