line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DOM::NodeList; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
13930
|
use strict; |
|
29
|
|
|
|
|
29
|
|
|
29
|
|
|
|
|
671
|
|
4
|
29
|
|
|
29
|
|
89
|
use warnings; |
|
29
|
|
|
|
|
31
|
|
|
29
|
|
|
|
|
1097
|
|
5
|
29
|
|
|
29
|
|
975
|
use overload fallback => 1, '@{}' => sub { ${$_[0]} }; |
|
29
|
|
|
373
|
|
733
|
|
|
29
|
|
|
|
|
185
|
|
|
373
|
|
|
|
|
757
|
|
|
373
|
|
|
|
|
1017
|
|
6
|
|
|
|
|
|
|
|
7
|
29
|
|
|
29
|
|
1447
|
use Scalar::Util 'weaken'; |
|
29
|
|
|
|
|
28
|
|
|
29
|
|
|
|
|
3135
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.057'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# new NodeList \@array; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
74
|
|
|
74
|
0
|
131348
|
bless do {\(my $x = $_[1])}, shift; |
|
74
|
|
|
|
|
485
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub item { |
19
|
349
|
50
|
|
349
|
1
|
218
|
${$_[0]}[$_[1]] || () |
|
349
|
|
|
|
|
465
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub length { |
23
|
67
|
|
|
67
|
1
|
52
|
scalar @${$_[0]} |
|
67
|
|
|
|
|
289
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1 __END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
HTML::DOM::NodeList - Simple node list class for HTML::DOM |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 VERSION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Version 0.057 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use HTML::DOM; |
39
|
|
|
|
|
|
|
$doc = HTML::DOM->new; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$list = $doc->body->childNodes; # returns an HTML::DOM::NodeList |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$list->[0]; # first node |
44
|
|
|
|
|
|
|
$list->item(0); # same |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$list->length; # same as scalar @$list |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This implements the NodeList interface as described in the W3C's DOM |
51
|
|
|
|
|
|
|
standard. In addition to the methods below, you can use a node list object |
52
|
|
|
|
|
|
|
as an array. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This class actually only implements those node lists that are based on |
55
|
|
|
|
|
|
|
array references (as returned by C methods). The |
56
|
|
|
|
|
|
|
L class is used for more |
57
|
|
|
|
|
|
|
complex node lists that call a code ref to update themselves. This is an |
58
|
|
|
|
|
|
|
implementation detail though, that you shouldn't have to worry about. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item $list->length |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns the number of items in the array. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item $list->item($index) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns item number C<$index>, numbered from 0. Note that you can also use |
71
|
|
|
|
|
|
|
C<< $list->[$index] >> for short. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L |