line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Upload; |
2
|
30
|
|
|
30
|
|
141
|
use strict; |
|
30
|
|
|
|
|
36
|
|
|
30
|
|
|
|
|
974
|
|
3
|
30
|
|
|
30
|
|
124
|
use warnings; |
|
30
|
|
|
|
|
39
|
|
|
30
|
|
|
|
|
622
|
|
4
|
30
|
|
|
30
|
|
120
|
use Carp (); |
|
30
|
|
|
|
|
40
|
|
|
30
|
|
|
|
|
608
|
|
5
|
30
|
|
|
30
|
|
115
|
use Scalar::Util qw/blessed/; |
|
30
|
|
|
|
|
34
|
|
|
30
|
|
|
|
|
7758
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
my %cache; |
9
|
|
|
|
|
|
|
sub _load { |
10
|
11
|
|
|
11
|
|
12
|
my $pkg = shift; |
11
|
11
|
100
|
|
|
|
37
|
unless ($cache{$pkg}++) { |
12
|
3
|
|
|
3
|
|
204
|
eval "use $pkg"; ## no critic |
|
3
|
|
|
|
|
1353
|
|
|
3
|
|
|
|
|
32
|
|
|
3
|
|
|
|
|
49
|
|
13
|
3
|
50
|
|
|
|
16
|
Carp::croak($@) if $@; |
14
|
|
|
|
|
|
|
} |
15
|
11
|
|
|
|
|
61
|
$pkg; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
12
|
|
|
12
|
0
|
23292
|
my ($self, $q, $name) = @_; |
22
|
12
|
50
|
|
|
|
28
|
Carp::croak("missing parameter \$name") unless $name; |
23
|
12
|
50
|
|
|
|
45
|
Carp::croak("\$q is not a object") unless blessed $q; |
24
|
|
|
|
|
|
|
|
25
|
12
|
|
|
|
|
14
|
my $pkg = do { |
26
|
12
|
100
|
|
|
|
93
|
if ($q->isa('CGI')) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
27
|
11
|
|
|
|
|
15
|
'CGI'; |
28
|
|
|
|
|
|
|
} elsif ($q->isa('HTTP::Engine::Request')) { |
29
|
0
|
|
|
|
|
0
|
'HTTPEngine'; |
30
|
|
|
|
|
|
|
} elsif ($q->isa('Plack::Request')) { |
31
|
0
|
|
|
|
|
0
|
'PlackRequest'; |
32
|
|
|
|
|
|
|
} else { |
33
|
1
|
50
|
|
|
|
9
|
if ($q->can('upload')){ # duck typing |
34
|
|
|
|
|
|
|
# this feature is needed by HTML::Shakan or other form validation libraries |
35
|
1
|
|
|
|
|
6
|
return $q->upload($name); # special case :) |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
0
|
die "unknown request type: $q"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
}; |
41
|
11
|
|
|
|
|
25
|
$pkg = 'FormValidator::Lite::Upload::' . $pkg; |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
20
|
_load($pkg)->new($q, $name); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |