I want to extract the tag name from an HTML tag with attributes.
For example, I have this tag
<a href="http://chat.stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })"
>
and I need to extract the tag name a
I have tried the following regex, but it doesn't work.
if ( $raw =~ /^<(\S*).*>$/ ) {
print "$1 is tag name of string\n";
}
What is wrong with my code?

HTML::TreeBuilder, as it is forgiving of the sort of malformed HTML that is found in the real world.