line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FormValidator::Lite::Upload; |
2
|
30
|
|
|
30
|
|
151
|
use strict; |
|
30
|
|
|
|
|
45
|
|
|
30
|
|
|
|
|
607
|
|
3
|
30
|
|
|
30
|
|
101
|
use warnings; |
|
30
|
|
|
|
|
46
|
|
|
30
|
|
|
|
|
498
|
|
4
|
30
|
|
|
30
|
|
100
|
use Carp (); |
|
30
|
|
|
|
|
47
|
|
|
30
|
|
|
|
|
515
|
|
5
|
30
|
|
|
30
|
|
114
|
use Scalar::Util qw/blessed/; |
|
30
|
|
|
|
|
38
|
|
|
30
|
|
|
|
|
6764
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
my %cache; |
9
|
|
|
|
|
|
|
sub _load { |
10
|
11
|
|
|
11
|
|
15
|
my $pkg = shift; |
11
|
11
|
100
|
|
|
|
32
|
unless ($cache{$pkg}++) { |
12
|
3
|
|
|
3
|
|
180
|
eval "use $pkg"; ## no critic |
|
3
|
|
|
|
|
1094
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
36
|
|
13
|
3
|
50
|
|
|
|
13
|
Carp::croak($@) if $@; |
14
|
|
|
|
|
|
|
} |
15
|
11
|
|
|
|
|
29
|
$pkg; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
12
|
|
|
12
|
0
|
36895
|
my ($self, $q, $name) = @_; |
22
|
12
|
50
|
|
|
|
38
|
Carp::croak("missing parameter \$name") unless $name; |
23
|
12
|
50
|
|
|
|
43
|
Carp::croak("\$q is not a object") unless blessed $q; |
24
|
|
|
|
|
|
|
|
25
|
12
|
|
|
|
|
16
|
my $pkg = do { |
26
|
12
|
100
|
|
|
|
50
|
if ($q->isa('CGI')) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
27
|
11
|
|
|
|
|
18
|
'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
|
|
|
|
5
|
if ($q->can('upload')){ # duck typing |
34
|
|
|
|
|
|
|
# this feature is needed by HTML::Shakan or other form validation libraries |
35
|
1
|
|
|
|
|
4
|
return $q->upload($name); # special case :) |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
0
|
die "unknown request type: $q"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
}; |
41
|
11
|
|
|
|
|
27
|
$pkg = 'FormValidator::Lite::Upload::' . $pkg; |
42
|
|
|
|
|
|
|
|
43
|
11
|
|
|
|
|
18
|
_load($pkg)->new($q, $name); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |