You haven't verified that HTML::TokeParser->new() succeeds, so you go on to call $p->get_tag() even though $p is empty.
The call to HTML::TokeParser->new() is probably failing because the script cannot find the specified file, or the script doesn't have the appropriate permissions to open it.