Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created October 12, 2010 23:08
Show Gist options
  • Save bigpresh/623090 to your computer and use it in GitHub Desktop.
Save bigpresh/623090 to your computer and use it in GitHub Desktop.
my $form = HTML::Form->parse($mech->response);
my $dropdown = $form->find_input('DropdownName');
my @labels = $dropdown->value_names;
my @values = $dropdown->possible_values;
# The above works perfectly for fetching a list of values and labels,
# but for each entry in the drop-down, I need to know which <optgroup>
# it's in. HTML::Form doesn't appear to provide that info...
<select name="fieldname">
<optgroup label="Optgroup One">
<option value="1">Foo</option>
<option value="2">Bar</option>
</optgroup>
<optgroup label="Optgroup Two">
<option value="3">Foo</option>
<option value="4">Bar</option>
</optgroup>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment