line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Pony::Pink; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36759
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
9902
|
use autodie; |
|
1
|
|
|
|
|
29720
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
6590
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
1
|
|
5
|
no warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
7
|
1
|
|
|
1
|
|
1234
|
use utf8; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
1
|
|
|
1
|
|
72
|
$Acme::Pony::Pink::AUTHORITY = 'cpan:TOBYINK'; |
11
|
1
|
|
|
|
|
21
|
$Acme::Pony::Pink::VERSION = '0.003'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
8
|
use Carp qw; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
71
|
|
15
|
1
|
|
|
1
|
|
983
|
use MIME::Base64 qw; |
|
1
|
|
|
|
|
869
|
|
|
1
|
|
|
|
|
70
|
|
16
|
1
|
|
|
1
|
|
968
|
use List::MoreUtils qw; |
|
1
|
|
|
|
|
1217
|
|
|
1
|
|
|
|
|
78
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
8
|
use Config; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
19
|
1
|
|
|
1
|
|
6
|
use constant _path_to_perl => $Config{perlpath}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
0
|
1
|
|
shift; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _image |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
|
|
state $image = do { |
29
|
0
|
|
|
|
|
|
local $/ = ; |
30
|
0
|
|
|
|
|
|
decode_base64($/); |
31
|
|
|
|
|
|
|
}; |
32
|
0
|
|
|
|
|
|
return $image; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _find_shebang |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
|
|
my ($class, $lines) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
my $idx = firstidx { /^\#\!.*\bperl\b/ } @$lines; |
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
return if $idx < 0; # no shebang |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# look for code before shebang... that's not a real shebang |
43
|
0
|
|
|
|
|
|
for (0 .. $idx) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
0
|
|
|
|
|
next if $lines->[$_] =~ m{^\s*#}; |
46
|
0
|
0
|
|
|
|
|
next if $lines->[$_] =~ m{^\s*$}; |
47
|
0
|
|
|
|
|
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $lines->[$idx]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _filehandle |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
|
|
my ($class, $args, $mode) = @_; |
56
|
0
|
0
|
|
|
|
|
return unless @$args; |
57
|
0
|
|
0
|
|
|
|
$mode //= '<'; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $arg = shift @$args; |
60
|
0
|
|
|
|
|
|
my $fh; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if (ref $arg eq 'SCALAR') |
|
|
0
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
{ open $fh, $mode, \$arg } |
64
|
|
|
|
|
|
|
elsif (!ref $arg) |
65
|
0
|
|
|
|
|
|
{ open $fh, $mode, $arg } |
66
|
|
|
|
|
|
|
else |
67
|
0
|
|
|
|
|
|
{ $fh = $arg } |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $fh; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub ponify |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
75
|
0
|
|
|
|
|
|
local $/ = "\n"; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
my $fh_in = $class->_filehandle(\@_, '<') or croak "must supply input handle"; |
78
|
0
|
|
0
|
|
|
|
my $fh_out = $class->_filehandle(\@_, '>') || \*STDOUT; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my @lines = <$fh_in>; |
81
|
0
|
0
|
|
|
|
|
unshift @lines, sprintf("#!%s\n", $class->_path_to_perl) |
82
|
|
|
|
|
|
|
unless $class->_find_shebang(\@lines); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
print {$fh_out} $class->_image; |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
print {$fh_out} qq(\n\n); |
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
print {$fh_out} @lines; |
|
0
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Acme::Pony::Pink - make your script look like a pink pony |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $converter = Acme::Pony::Pink->new; |
97
|
|
|
|
|
|
|
$converter->ponify('myscript.pl' => 'myscript.gif'); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
myscript.gif is now a small picture of a pink pony, and you can run the |
100
|
|
|
|
|
|
|
original script using: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
perl -x myscript.gif |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 DESCRIPTION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This module turns a Perl script into a picture of a pink pony. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The picture is executable via C<< perl -x >>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 Unconstrutive Constructor |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item C<< new >> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the invocant. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 Method |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item C<< ponify($input, $output) >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The input is a Perl script; the output is a GIF file. (No, the "F" in "GIF" |
127
|
|
|
|
|
|
|
does not stand for "file".) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Input and output may be filehandles, file names, or scalar references if you |
130
|
|
|
|
|
|
|
just want to play with strings. The input source is required; the default |
131
|
|
|
|
|
|
|
output destination is STDOUT. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 BUGS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Please report any bugs to someone who cares. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L, |
142
|
|
|
|
|
|
|
L. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Toby Inkster Etobyink@cpan.orgE. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Toby Inkster. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
153
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
158
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
159
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__PACKAGE__ |
164
|
|
|
|
|
|
|
__DATA__ |