 <p>Keep it simple. How about this?</p> <pre><code>while ( my $tag = $parser-&gt;get_tag('input') ) { my $name = $tag-&gt;get_attr('name'); next unless defined $name and $name eq 'hush_username'; print "Value: ", $tag-&gt;get_attr('value'), "\n"; } </code></pre>