| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package CGI::Form::Table::Reader; |
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
32585
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
228
|
|
|
5
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
1331
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.161'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
CGI::Form::Table::Reader - read a table of form inputs |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.161 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$Id: /my/cs/projects/formtable/trunk/lib/CGI/Form/Table/Reader.pm 27836 2006-11-11T04:19:45.102963Z rjbs $ |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use CGI; |
|
22
|
|
|
|
|
|
|
use CGI::Form::Table::Reader; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $query = CGI->new; |
|
25
|
|
|
|
|
|
|
my $form = CGI::Form::Table::Reader->new(query => $query, prefix => 'user'); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $users = $form->rows; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 C<< CGI::Form::Table::Reader->new(query => $query, prefix => $prefix) >> |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
|
39
|
6
|
|
|
6
|
1
|
12393
|
my ($class, %args) = @_; |
|
40
|
6
|
100
|
100
|
|
|
51
|
return unless $args{prefix} and $args{query}; |
|
41
|
3
|
|
|
|
|
17
|
bless \%args => $class; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 C<< CGI::Form::Table::Reader->rows >> |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns an arrayref of hashrefs from the CGI inputs with the given prefix. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub rows { |
|
51
|
2
|
|
|
2
|
1
|
8
|
my ($self) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
9
|
my @positions = $self->_read_positions; |
|
54
|
2
|
100
|
|
|
|
36
|
return unless @positions; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
2
|
my @rows; |
|
57
|
1
|
|
|
|
|
6
|
push @rows, $self->_read_row($_) for @positions; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
6
|
\@rows; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _read_row { |
|
63
|
3
|
|
|
3
|
|
6
|
my ($self, $position) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
8
|
my $row_prefix = $self->{prefix} . '_' . $position . '_'; |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
4
|
my %row; |
|
68
|
3
|
|
|
|
|
12
|
for (grep { /^$row_prefix/ } $self->{query}->param) { |
|
|
45
|
|
|
|
|
195
|
|
|
69
|
15
|
|
|
|
|
277
|
(my $name = $_) =~ s/^$row_prefix//; |
|
70
|
15
|
|
|
|
|
48
|
$row{$name} = $self->{query}->param($_); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
69
|
return \%row; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# _read_positions |
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
# returns a list of the positions found in the params |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _read_positions { |
|
81
|
2
|
|
|
2
|
|
5
|
my ($self) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
4
|
my %temp; |
|
84
|
3
|
|
|
|
|
15
|
my @positions = |
|
85
|
15
|
|
|
|
|
43
|
sort { $a <=> $b } |
|
86
|
15
|
|
|
|
|
103
|
grep { ! $temp{0+$_} ++ } |
|
87
|
2
|
|
|
|
|
11
|
map { /^$self->{prefix}_(\d+)_/; } |
|
88
|
|
|
|
|
|
|
$self->{query}->param; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Ricardo SIGNES, C<< >> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 BUGS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
|
98
|
|
|
|
|
|
|
L. I will be notified, and then you'll automatically be |
|
99
|
|
|
|
|
|
|
notified of progress on your bug as I make changes. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright 2004 Ricardo SIGNES, All Rights Reserved. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
106
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |