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