| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Pastebin::PastebinCom::Create; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
320001
|
use Moo; |
|
|
2
|
|
|
|
|
17463
|
|
|
|
2
|
|
|
|
|
16
|
|
|
4
|
2
|
|
|
2
|
|
3672
|
use WWW::Mechanize; |
|
|
2
|
|
|
|
|
208967
|
|
|
|
2
|
|
|
|
|
160
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
21
|
use overload q{""} => sub { return shift->paste_uri }; |
|
|
2
|
|
|
1
|
|
5
|
|
|
|
2
|
|
|
|
|
23
|
|
|
|
1
|
|
|
|
|
1965
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has error => ( is => 'rw', build_arg => undef, ); |
|
10
|
|
|
|
|
|
|
has paste_uri => ( is => 'rw', build_arg => undef, ); |
|
11
|
|
|
|
|
|
|
has _mech => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
build_arg => undef, |
|
14
|
|
|
|
|
|
|
default => sub { |
|
15
|
|
|
|
|
|
|
my $mech = WWW::Mechanize->new( |
|
16
|
|
|
|
|
|
|
timeout => 30, |
|
17
|
|
|
|
|
|
|
autocheck => 0, |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
$mech->agent_alias('Linux Mozilla'); |
|
20
|
|
|
|
|
|
|
return $mech; |
|
21
|
|
|
|
|
|
|
}, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub paste { |
|
25
|
2
|
|
|
2
|
1
|
24
|
my ( $self, %args ) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
20
|
$self->paste_uri(undef); |
|
28
|
2
|
|
|
|
|
10
|
$self->error(undef); |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
11
|
%args = __process_args( %args ); |
|
31
|
2
|
100
|
66
|
|
|
92
|
defined $args{text} |
|
32
|
|
|
|
|
|
|
and length $args{text} |
|
33
|
|
|
|
|
|
|
or return $self->_set_error('Paste text is empty'); |
|
34
|
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
5
|
my $mech = $self->_mech; |
|
36
|
1
|
|
|
|
|
5
|
$mech->get('http://pastebin.com'); |
|
37
|
1
|
50
|
|
|
|
323794
|
$mech->success or return $self->_set_mech_error; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
34
|
$mech->form_name('myform') |
|
40
|
|
|
|
|
|
|
or return $self->_set_error('Paste form not found'); |
|
41
|
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
107690
|
$mech->set_fields( |
|
43
|
|
|
|
|
|
|
paste_code => $args{text}, |
|
44
|
|
|
|
|
|
|
paste_format => $args{format}, |
|
45
|
|
|
|
|
|
|
paste_expire_date => $args{expiry}, |
|
46
|
|
|
|
|
|
|
paste_private => $args{private}, |
|
47
|
|
|
|
|
|
|
paste_name => $args{desc}, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
1
|
|
|
|
|
583
|
$mech->submit; |
|
50
|
1
|
50
|
|
|
|
384322
|
$mech->success or return $self->_set_mech_error; |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
35
|
my $uri = '' . $mech->uri; |
|
53
|
1
|
50
|
|
|
|
52
|
$uri =~ m{/index\.php} |
|
54
|
|
|
|
|
|
|
and return $self->_set_error(q{Didn't get a valid paste URI}); |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
50
|
|
|
|
7
|
$uri =~ m{/warning\.php} |
|
57
|
|
|
|
|
|
|
and return $self->_set_error(q{Reached the paste limit. See } . |
|
58
|
|
|
|
|
|
|
$uri . q{ for details.} |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
17
|
return $self->paste_uri( $uri ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub __process_args { |
|
65
|
2
|
|
|
2
|
|
8
|
my %args = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
16
|
$args{+lc} = delete $args{$_} for keys %args; |
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
50
|
66
|
|
|
23
|
$args{desc} = substr($args{desc}, 0, 57) . '...' |
|
70
|
|
|
|
|
|
|
if defined $args{desc} |
|
71
|
|
|
|
|
|
|
and length $args{desc} > 60; |
|
72
|
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
9
|
my $valid_formats = __get_valid_formats(); |
|
74
|
2
|
|
100
|
|
|
20
|
$args{format} = $valid_formats->{ lc($args{format} || '') }; |
|
75
|
2
|
100
|
|
|
|
9
|
$args{format} = $valid_formats->{none} |
|
76
|
|
|
|
|
|
|
unless defined $args{format}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
7
|
my $valid_expiry = __get_valid_expiry(); |
|
79
|
2
|
|
100
|
|
|
15
|
$args{expiry} = $valid_expiry->{ lc($args{expiry} || '') }; |
|
80
|
2
|
100
|
|
|
|
8
|
$args{expiry} = $valid_expiry->{m} |
|
81
|
|
|
|
|
|
|
unless defined $args{expiry}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
2
|
50
|
33
|
|
|
89
|
$args{private} = 1 |
|
84
|
|
|
|
|
|
|
unless defined $args{private} |
|
85
|
|
|
|
|
|
|
and $args{private} eq '0'; |
|
86
|
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
49
|
return %args; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _set_mech_error { |
|
91
|
0
|
|
|
0
|
|
0
|
my ( $self, $mech ) = @_; |
|
92
|
0
|
|
|
|
|
0
|
$self->error( |
|
93
|
|
|
|
|
|
|
'Network error: ' . $mech->res->code . ' ' . $mech->res->status_line |
|
94
|
|
|
|
|
|
|
); |
|
95
|
0
|
|
|
|
|
0
|
return; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _set_error { |
|
99
|
1
|
|
|
1
|
|
4
|
my ( $self, $error ) = @_; |
|
100
|
1
|
|
|
|
|
5
|
$self->error( $error ); |
|
101
|
1
|
|
|
|
|
8
|
return; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub __get_valid_expiry { |
|
105
|
|
|
|
|
|
|
return { |
|
106
|
|
|
|
|
|
|
# 10 Minutes |
|
107
|
2
|
|
|
2
|
|
117
|
'10m' => '10M', |
|
108
|
|
|
|
|
|
|
m10 => '10M', |
|
109
|
|
|
|
|
|
|
asap => '10M', |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# 1 Hour |
|
112
|
|
|
|
|
|
|
h => '1H', |
|
113
|
|
|
|
|
|
|
'1h' => '1H', |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# 1 Day |
|
116
|
|
|
|
|
|
|
d => '1D', |
|
117
|
|
|
|
|
|
|
'1d' => '1D', |
|
118
|
|
|
|
|
|
|
soon => '1D', |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# 1 Week |
|
121
|
|
|
|
|
|
|
w => '1W', |
|
122
|
|
|
|
|
|
|
'1w' => '1W', |
|
123
|
|
|
|
|
|
|
awhile => '1W', |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
'2w' => '2W', |
|
126
|
|
|
|
|
|
|
w2 => '2W', |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# 1 Month |
|
129
|
|
|
|
|
|
|
'1m' => '1M', |
|
130
|
|
|
|
|
|
|
m => '1M', |
|
131
|
|
|
|
|
|
|
m1 => '1M', |
|
132
|
|
|
|
|
|
|
eventually => '1M', |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Never |
|
135
|
|
|
|
|
|
|
n => 'N', |
|
136
|
|
|
|
|
|
|
never => 'N', |
|
137
|
|
|
|
|
|
|
}; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub __get_valid_formats { |
|
141
|
2
|
|
|
2
|
|
211
|
my %formats = ( |
|
142
|
|
|
|
|
|
|
'None' => '1', |
|
143
|
|
|
|
|
|
|
'Bash' => '8', |
|
144
|
|
|
|
|
|
|
'C' => '9', |
|
145
|
|
|
|
|
|
|
'C#' => '14', |
|
146
|
|
|
|
|
|
|
'C++' => '13', |
|
147
|
|
|
|
|
|
|
'CSS' => '16', |
|
148
|
|
|
|
|
|
|
'HTML' => '25', |
|
149
|
|
|
|
|
|
|
'HTML 5' => '196', |
|
150
|
|
|
|
|
|
|
'Java' => '27', |
|
151
|
|
|
|
|
|
|
'JavaScript' => '28', |
|
152
|
|
|
|
|
|
|
'Lua' => '30', |
|
153
|
|
|
|
|
|
|
'None' => '1', |
|
154
|
|
|
|
|
|
|
'Objective C' => '35', |
|
155
|
|
|
|
|
|
|
'Perl' => '40', |
|
156
|
|
|
|
|
|
|
'PHP' => '41', |
|
157
|
|
|
|
|
|
|
'Python' => '42', |
|
158
|
|
|
|
|
|
|
'Rails' => '67', |
|
159
|
|
|
|
|
|
|
'4CS' => '142', |
|
160
|
|
|
|
|
|
|
'6502 ACME Cross Assembler' => '143', |
|
161
|
|
|
|
|
|
|
'6502 Kick Assembler' => '144', |
|
162
|
|
|
|
|
|
|
'6502 TASM/64TASS' => '145', |
|
163
|
|
|
|
|
|
|
'ABAP' => '73', |
|
164
|
|
|
|
|
|
|
'ActionScript' => '2', |
|
165
|
|
|
|
|
|
|
'ActionScript 3' => '74', |
|
166
|
|
|
|
|
|
|
'Ada' => '3', |
|
167
|
|
|
|
|
|
|
'ALGOL 68' => '147', |
|
168
|
|
|
|
|
|
|
'Apache Log' => '4', |
|
169
|
|
|
|
|
|
|
'AppleScript' => '5', |
|
170
|
|
|
|
|
|
|
'APT Sources' => '75', |
|
171
|
|
|
|
|
|
|
'ARM' => '217', |
|
172
|
|
|
|
|
|
|
'ASM (NASM)' => '6', |
|
173
|
|
|
|
|
|
|
'ASP' => '7', |
|
174
|
|
|
|
|
|
|
'Asymptote' => '218', |
|
175
|
|
|
|
|
|
|
'autoconf' => '148', |
|
176
|
|
|
|
|
|
|
'Autohotkey' => '149', |
|
177
|
|
|
|
|
|
|
'AutoIt' => '54', |
|
178
|
|
|
|
|
|
|
'Avisynth' => '76', |
|
179
|
|
|
|
|
|
|
'Awk' => '150', |
|
180
|
|
|
|
|
|
|
'BASCOM AVR' => '198', |
|
181
|
|
|
|
|
|
|
'Bash' => '8', |
|
182
|
|
|
|
|
|
|
'Basic4GL' => '77', |
|
183
|
|
|
|
|
|
|
'BibTeX' => '78', |
|
184
|
|
|
|
|
|
|
'Blitz Basic' => '55', |
|
185
|
|
|
|
|
|
|
'BNF' => '56', |
|
186
|
|
|
|
|
|
|
'BOO' => '80', |
|
187
|
|
|
|
|
|
|
'BrainFuck' => '79', |
|
188
|
|
|
|
|
|
|
'C' => '9', |
|
189
|
|
|
|
|
|
|
'C for Macs' => '10', |
|
190
|
|
|
|
|
|
|
'C Intermediate Language' => '82', |
|
191
|
|
|
|
|
|
|
'C#' => '14', |
|
192
|
|
|
|
|
|
|
'C++' => '13', |
|
193
|
|
|
|
|
|
|
'C++ (with QT extensions)' => '154', |
|
194
|
|
|
|
|
|
|
'C: Loadrunner' => '199', |
|
195
|
|
|
|
|
|
|
'CAD DCL' => '11', |
|
196
|
|
|
|
|
|
|
'CAD Lisp' => '12', |
|
197
|
|
|
|
|
|
|
'CFDG' => '81', |
|
198
|
|
|
|
|
|
|
'ChaiScript' => '152', |
|
199
|
|
|
|
|
|
|
'Clojure' => '153', |
|
200
|
|
|
|
|
|
|
'Clone C' => '99', |
|
201
|
|
|
|
|
|
|
'Clone C++' => '100', |
|
202
|
|
|
|
|
|
|
'CMake' => '83', |
|
203
|
|
|
|
|
|
|
'COBOL' => '84', |
|
204
|
|
|
|
|
|
|
'CoffeeScript' => '200', |
|
205
|
|
|
|
|
|
|
'ColdFusion' => '15', |
|
206
|
|
|
|
|
|
|
'CSS' => '16', |
|
207
|
|
|
|
|
|
|
'Cuesheet' => '151', |
|
208
|
|
|
|
|
|
|
'D' => '17', |
|
209
|
|
|
|
|
|
|
'DCL' => '219', |
|
210
|
|
|
|
|
|
|
'DCPU-16' => '220', |
|
211
|
|
|
|
|
|
|
'DCS' => '85', |
|
212
|
|
|
|
|
|
|
'Delphi' => '18', |
|
213
|
|
|
|
|
|
|
'Delphi Prism (Oxygene)' => '177', |
|
214
|
|
|
|
|
|
|
'Diff' => '19', |
|
215
|
|
|
|
|
|
|
'DIV' => '86', |
|
216
|
|
|
|
|
|
|
'DOS' => '20', |
|
217
|
|
|
|
|
|
|
'DOT' => '87', |
|
218
|
|
|
|
|
|
|
'E' => '155', |
|
219
|
|
|
|
|
|
|
'ECMAScript' => '156', |
|
220
|
|
|
|
|
|
|
'Eiffel' => '21', |
|
221
|
|
|
|
|
|
|
'Email' => '88', |
|
222
|
|
|
|
|
|
|
'EPC' => '201', |
|
223
|
|
|
|
|
|
|
'Erlang' => '57', |
|
224
|
|
|
|
|
|
|
'F#' => '158', |
|
225
|
|
|
|
|
|
|
'Falcon' => '202', |
|
226
|
|
|
|
|
|
|
'FO Language' => '89', |
|
227
|
|
|
|
|
|
|
'Formula One' => '157', |
|
228
|
|
|
|
|
|
|
'Fortran' => '22', |
|
229
|
|
|
|
|
|
|
'FreeBasic' => '23', |
|
230
|
|
|
|
|
|
|
'FreeSWITCH' => '206', |
|
231
|
|
|
|
|
|
|
'GAMBAS' => '159', |
|
232
|
|
|
|
|
|
|
'Game Maker' => '24', |
|
233
|
|
|
|
|
|
|
'GDB' => '160', |
|
234
|
|
|
|
|
|
|
'Genero' => '58', |
|
235
|
|
|
|
|
|
|
'Genie' => '161', |
|
236
|
|
|
|
|
|
|
'GetText' => '90', |
|
237
|
|
|
|
|
|
|
'Go' => '162', |
|
238
|
|
|
|
|
|
|
'Groovy' => '59', |
|
239
|
|
|
|
|
|
|
'GwBasic' => '163', |
|
240
|
|
|
|
|
|
|
'Haskell' => '60', |
|
241
|
|
|
|
|
|
|
'Haxe' => '221', |
|
242
|
|
|
|
|
|
|
'HicEst' => '164', |
|
243
|
|
|
|
|
|
|
'HQ9 Plus' => '93', |
|
244
|
|
|
|
|
|
|
'HTML' => '25', |
|
245
|
|
|
|
|
|
|
'HTML 5' => '196', |
|
246
|
|
|
|
|
|
|
'Icon' => '165', |
|
247
|
|
|
|
|
|
|
'IDL' => '94', |
|
248
|
|
|
|
|
|
|
'INI file' => '26', |
|
249
|
|
|
|
|
|
|
'Inno Script' => '61', |
|
250
|
|
|
|
|
|
|
'INTERCAL' => '95', |
|
251
|
|
|
|
|
|
|
'IO' => '96', |
|
252
|
|
|
|
|
|
|
'J' => '166', |
|
253
|
|
|
|
|
|
|
'Java' => '27', |
|
254
|
|
|
|
|
|
|
'Java 5' => '97', |
|
255
|
|
|
|
|
|
|
'JavaScript' => '28', |
|
256
|
|
|
|
|
|
|
'jQuery' => '167', |
|
257
|
|
|
|
|
|
|
); |
|
258
|
|
|
|
|
|
|
|
|
259
|
2
|
|
|
|
|
336
|
$formats{+lc} = delete $formats{$_} for keys %formats; |
|
260
|
|
|
|
|
|
|
|
|
261
|
2
|
|
|
|
|
29
|
return \%formats; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
q| |
|
265
|
|
|
|
|
|
|
Q: Whats the object-oriented way to become wealthy? |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
A: Inheritance |
|
268
|
|
|
|
|
|
|
|; |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
__END__ |