in reply to A question about HTML::TokeParser
And the debug output shows:... while (my $token = $parser->get_token) { next unless $token->[1] =~ /(?:select|input|textarea)/; if ($token->[0] eq 'S') # start tag { $count++; my $tag = $token->[1]; my $name = $token->[2]{name}; # fetch name of input my $value = $token->[2]{value}; my $maxlength = $token->[2]{maxlength}; my $required = $token->[2]{required}; my $allowed; if ($tag eq 'select') { while (my $option = $parser->get_token) { last if $option->[0] eq 'E' && $option->[1] eq 'select'; next unless $option->[0] eq 'S' && $option->[1] eq 'option'; push @{$allowed}, $option->[2]{value}; } } else { $allowed = [ $token->[2]{allowed} ]; } $DEBUG && print "$count\t$tag\t$name\t\n"; if ($tag eq 'select') { print Dumper($allowed); } } ... }
1 input text1 2 textarea textarea1 3 input radio1 4 input radio1 5 input check1 6 input check1 7 select list1 $VAR1 = [ '1', '2', '3' ]; 8 input text2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A question about HTML::TokeParser
by theguvnor (Chaplain) on Oct 14, 2003 at 13:09 UTC |