line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Pure::Save; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
78377
|
use strict; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
148
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
138
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
1086
|
use Class::Utils qw(set_params); |
|
5
|
|
|
|
|
60700
|
|
|
5
|
|
|
|
|
208
|
|
7
|
5
|
|
|
5
|
|
180
|
use English qw(-no_match_vars); |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
27
|
|
8
|
5
|
|
|
5
|
|
1920
|
use Error::Pure qw(err); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
222
|
|
9
|
5
|
|
|
5
|
|
30
|
use Readonly; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
192
|
|
10
|
5
|
|
|
5
|
|
1056
|
use URI::Escape; |
|
5
|
|
|
|
|
3051
|
|
|
5
|
|
|
|
|
2453
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Constants. |
13
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.09; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Constructor. |
18
|
|
|
|
|
|
|
sub new { |
19
|
4
|
|
|
4
|
1
|
126
|
my ($class, @params) = @_; |
20
|
4
|
|
|
|
|
12
|
my $self = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# CGI::Pure object. |
23
|
4
|
|
|
|
|
18
|
$self->{'cgi_pure'} = $EMPTY_STR; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Process params. |
26
|
4
|
|
|
|
|
31
|
set_params($self, @params); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# CGI::Pure object not exist. |
29
|
4
|
100
|
66
|
|
|
85
|
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
|
|
|
|
|
12
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Load parameters from file. |
38
|
|
|
|
|
|
|
sub load { |
39
|
1
|
|
|
1
|
1
|
111
|
my ($self, $fh) = @_; |
40
|
1
|
50
|
33
|
|
|
9
|
if (! $fh || ! fileno $fh) { |
41
|
0
|
|
|
|
|
0
|
err 'Invalid filehandle.'; |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
5
|
local $INPUT_RECORD_SEPARATOR = "\n"; |
44
|
1
|
|
|
|
|
28
|
while (my $pair = <$fh>) { |
45
|
3
|
|
|
|
|
6
|
chomp $pair; |
46
|
3
|
100
|
|
|
|
14
|
if ($pair eq q{=}) { |
47
|
1
|
|
|
|
|
5
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
21
|
$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
|
263
|
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
|
|
|
18
|
if (! $fh || ! fileno $fh) { |
60
|
0
|
|
|
|
|
0
|
err 'Invalid filehandle.'; |
61
|
|
|
|
|
|
|
} |
62
|
1
|
|
|
|
|
7
|
foreach my $param ($self->{'cgi_pure'}->param) { |
63
|
2
|
|
|
|
|
74
|
foreach my $value ($self->{'cgi_pure'}->param($param)) { |
64
|
2
|
|
|
|
|
4
|
print {$fh} uri_escape($param), '=', |
|
2
|
|
|
|
|
7
|
|
65
|
|
|
|
|
|
|
uri_escape($value), "\n"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
1
|
|
|
|
|
23
|
print {$fh} "=\n"; |
|
1
|
|
|
|
|
6
|
|
69
|
1
|
|
|
|
|
5
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |