line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Pure::Save; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
75539
|
use strict; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
143
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
131
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
958
|
use Class::Utils qw(set_params); |
|
5
|
|
|
|
|
56838
|
|
|
5
|
|
|
|
|
160
|
|
7
|
5
|
|
|
5
|
|
153
|
use English qw(-no_match_vars); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
23
|
|
8
|
5
|
|
|
5
|
|
1665
|
use Error::Pure qw(err); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
198
|
|
9
|
5
|
|
|
5
|
|
27
|
use Readonly; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
232
|
|
10
|
5
|
|
|
5
|
|
986
|
use URI::Escape; |
|
5
|
|
|
|
|
3117
|
|
|
5
|
|
|
|
|
2262
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constants. |
13
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.08; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Constructor. |
18
|
|
|
|
|
|
|
sub new { |
19
|
4
|
|
|
4
|
1
|
120
|
my ($class, @params) = @_; |
20
|
4
|
|
|
|
|
14
|
my $self = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# CGI::Pure object. |
23
|
4
|
|
|
|
|
20
|
$self->{'cgi_pure'} = $EMPTY_STR; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Process params. |
26
|
4
|
|
|
|
|
17
|
set_params($self, @params); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# CGI::Pure object not exist. |
29
|
4
|
100
|
66
|
|
|
97
|
if (! $self->{'cgi_pure'} || ! $self->{'cgi_pure'}->isa('CGI::Pure')) { |
30
|
1
|
|
|
|
|
6
|
err 'CGI::Pure object doesn\'t define.'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Object. |
34
|
3
|
|
|
|
|
14
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Load parameters from file. |
38
|
|
|
|
|
|
|
sub load { |
39
|
1
|
|
|
1
|
1
|
98
|
my ($self, $fh) = @_; |
40
|
1
|
50
|
33
|
|
|
28
|
if (! $fh || ! fileno $fh) { |
41
|
0
|
|
|
|
|
0
|
err 'Invalid filehandle.'; |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
6
|
local $INPUT_RECORD_SEPARATOR = "\n"; |
44
|
1
|
|
|
|
|
36
|
while (my $pair = <$fh>) { |
45
|
3
|
|
|
|
|
8
|
chomp $pair; |
46
|
3
|
100
|
|
|
|
8
|
if ($pair eq q{=}) { |
47
|
1
|
|
|
|
|
20
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
7
|
$self->{'cgi_pure'}->_parse_params($pair); |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
0
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Save parameters to file. |
55
|
|
|
|
|
|
|
sub save { |
56
|
1
|
|
|
1
|
1
|
182
|
my ($self, $fh) = @_; |
57
|
1
|
|
|
|
|
4
|
local $OUTPUT_FIELD_SEPARATOR = $EMPTY_STR; |
58
|
1
|
|
|
|
|
5
|
local $OUTPUT_RECORD_SEPARATOR = $EMPTY_STR; |
59
|
1
|
50
|
33
|
|
|
26
|
if (! $fh || ! fileno $fh) { |
60
|
0
|
|
|
|
|
0
|
err 'Invalid filehandle.'; |
61
|
|
|
|
|
|
|
} |
62
|
1
|
|
|
|
|
6
|
foreach my $param ($self->{'cgi_pure'}->param) { |
63
|
2
|
|
|
|
|
81
|
foreach my $value ($self->{'cgi_pure'}->param($param)) { |
64
|
2
|
|
|
|
|
3
|
print {$fh} uri_escape($param), '=', |
|
2
|
|
|
|
|
16
|
|
65
|
|
|
|
|
|
|
uri_escape($value), "\n"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
1
|
|
|
|
|
22
|
print {$fh} "=\n"; |
|
1
|
|
|
|
|
2
|
|
69
|
1
|
|
|
|
|
5
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |