use strict; use Test::More (tests => 93); BEGIN { use_ok("HTML::Parser::Stacked"); } my $p = HTML::Parser::Stacked->new( start_h => [ [ \&collect_a, \&collect_img ], "self,tag,attr" ] ); ok($p); isa_ok($p, 'HTML::Parser::Stacked'); my $link_count = 0; my $img_count = 0; sub collect_a { my ($self, $tag, $attr) = @_; is(scalar @_, 3); isa_ok($self, "HTML::Parser::Stacked"); is(ref $tag, ''); isa_ok($attr, 'HASH'); if ($tag eq 'a') { $link_count++; } } sub collect_img { my ($self, $tag, $attr) = @_; is(scalar @_, 3); isa_ok($self, "HTML::Parser::Stacked"); is(ref $tag, ''); isa_ok($attr, 'HASH'); if ($tag eq 'img') { $img_count++; } } $p->parse(< link1 link2 link3 link4 EOHTML $p->eof; is($link_count, 4); is($img_count, 5);