http://www.perlmonks.org?node_id=426150


in reply to Trouble Parsing HTML

TMTOWTDI, that's for sure! :-)
#!/usr/bin/perl -w use strict; use HTML::TokeParser; my $p = HTML::TokeParser->new( *DATA ); for (my $token = $p->get_tag("select")) { my $select = $token->[1]{name} ; print "$select\n"; } while (my $token2 = $p->get_tag("option")) { if ($token2->[1]{selected}) { my $option = $p->get_text("option"); print "$option\n"; } } __DATA__ <select name="cmbPurpose" id="cmbPurpose" tabindex="3"> <option value="CD">Cell Development</option> <option value="MS">Miscellaneous R&amp;D</option> <option value="NP">New Package</option> <option value="NR">Non R&amp;D</option> <option value="PC">New process</option> <option selected="selected" value="PD">New product</option> <option value="SP">Sustaining Product</option> <option value="SW">Software and Platform</option> <option value="TD">Technology Development</option>