#!/bin/perl5 use strict; use warnings; use HTML::TokeParser::Simple; my $select; { local $/; $select = ; } my $tp = HTML::TokeParser::Simple->new(\$select) or die "Couldn't parse string: $!"; my ($start, @states); while (my $t = $tp->get_token) { $start++, next if $t->is_start_tag('select'); next unless $start; last if $t->is_end_tag('/select'); push @states, $t->get_attr('value') if $t->is_start_tag('option'); } print "$_\n" for @states; __DATA__