Specify multiple classes in HTML :: Element look_down for Perl?

I am using HTML :: TreeBuilder to parse some HTML.

Can you specify multiple classes in the look_down procedure ?

To search in search mode using HTML -

for ( $tree->look_down( 'class' => 'postbody'))

I also had to look for an extra class 'postprofile'in the same loop.

Is there a way to do this without using a new one - for ( $tree->look_down( 'class' => 'postprofile' ))

Since this returns two result sets, while I only need one combined set.

I tried to use - for ( $tree->look_down( 'class' => 'postbody||postprofile')) However, this did not work,

Thanks in advance.

+5
source share
2 answers

, ..

$tree->look_down( 'class' => qr/^(?:postbody|postprofile)$/)
+9

, , , , . .

, , . :

  • search.cpan.org - , CPAN . .

  • perldoc.perl.org Perl.

:

  • perldoc , , .

  • perldoc -f function - perlfunc . .

  • perldoc Module::Name::Here .

  • perldoc perlpod - , POD.

?

, , ? , , "look_down", . ?

, "look_down" $somevar->look_down(blarg). $somevar. ? , - , THAT , . . . my $tree = HTML::TreeBuilder->new_from_content() - . new_from_content HTML:: TreeBuilder. , HTML:: Tree, HTML:: Element! . Whoah, look_down HTML:: Element.

, , . , , , :

use Some::Module qw( useful_sub  confusing_sub );

, useful_sub confusing_sub Some::Module;

, use Some::Module;, , . , , , .

, , . NOTHING, : use Some::Module ();

, . perldoc.

, , . R-ing TFM - , , , - , . Perl , , , , .

+1

All Articles