@@ -2175,13 +2175,13 @@ $collection->each(sub {
21752175### map
21762176
21772177``` perl
2178- my $result = $collection -> map (sub {
2178+ my $new_collection = $collection -> map (sub {
21792179 my ($token , $index ) = @_ ;
21802180 return " FOUND: " .$node -> tag." => $index " ;
21812181});
21822182
21832183# Also can bypass additional arguments
2184- my $result = $collection -> map (sub {
2184+ my $new_collection = $collection -> map (sub {
21852185 my ($token , $index , $title ) = @_ ;
21862186 return $title .$node -> tag." => $index " ;
21872187}, " FOUND: " );
@@ -2190,7 +2190,7 @@ my $result = $collection->map(sub {
21902190Apply callback for each node in collection. Returns new array from results.
21912191
21922192``` perl
2193- my $result = $collection -> map ($method , @args );
2193+ my $new_collection = $collection -> map ($method , @args );
21942194```
21952195
21962196Call method for each node in collection. Returns new [ HTML5::DOM::Collection] ( #html5domcollection ) from results.
@@ -2199,10 +2199,10 @@ Example:
21992199
22002200``` perl
22012201# set text 'test!' for all nodes
2202- my $result = $collection -> map (' text' , ' test!' );
2202+ $collection -> map (' text' , ' test!' );
22032203
22042204# get all tag names as array
2205- my $result = $collection -> map (' tag' );
2205+ my $new_collection = $collection -> map (' tag' );
22062206
22072207# remove all nodes in collection
22082208$collection -> map (' remove' );
@@ -2240,14 +2240,14 @@ print $collection->length; # 3
22402240### grep
22412241
22422242``` perl
2243- my $node = $collection -> grep (qr / regexp/ );
2243+ my $new_collection = $collection -> grep (qr / regexp/ );
22442244```
22452245
22462246Evaluates regexp for html code of each element in collection and creates new collection with all matched elements.
22472247
22482248``` perl
2249- my $node = $collection -> grep (sub {...});
2250- my $node = $collection -> grep (sub {...}, @args );
2249+ my $new_collection = $collection -> grep (sub {...});
2250+ my $new_collection = $collection -> grep (sub {...}, @args );
22512251```
22522252
22532253Evaluates callback foreach element in collection and creates new collection with all elements for which callback returned true.
@@ -2448,7 +2448,7 @@ print join(', ', @{$collection->head(2)->map('text')}; # Linux, OSX
24482448### tail
24492449
24502450```perl
2451- my $new_collection = $collection ->head ($length );
2451+ my $new_collection = $collection ->tail ($length );
24522452```
24532453
24542454Returns copy of collection with only last `$length ` items.
0 commit comments