Value options
--#--
The other elements we got by name. These, we got the whole gorilla.
First we have to extract the name, so we can match the right value
to the option within the <select>
@selects = getSelects($html_contents);
foreach (@selects) {
$name = selectName($_);
...
sub selectName {
my ($select) = @_;
if ($select =~ /name="?(\w*)"?/si) {
return $1;
}
else { return ""; }
}
Now it's time to tag the select option that was selected. We do
this by making a copy of the whole <select> element, and
substituting the copy for the original.
Note that there are (at least) two ways of writing a <select>.
Since the value term may or may not be present, we need
to present two options.
if (/value="$val"/i) {
$new_select =~ s/(
Putting this all together, the final step is the most mundane
substitution we've done all night.