... 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); } } ... }