Your parsing is very broken. You are making a whole load of invalid assumptions about the structure of a meta tag. You don't have to look very far for common examples of HTML syntax that breaks your parser. Perlmonks for example has meta tags. Your code does not extract them...... Please learn to use HTML::Parser or learn a lot more about what is and is not valid HTML.

use LWP::Simple; use HTML::Parser; use Data::Dumper; my $data = get('http://www.spydersubmission.com'); my $p = HTML::Parser->new( api_version => 3, start_h => [ \&start, "self,tagname,attr" ], ); sub start { my ( $self, $tagname, $attr ) = @_; return unless $tagname eq 'meta'; my $name = $attr->{name} || $attr->{'http-equiv'} || undef; return unless defined $name; $self->{meta}->{$name} = $attr->{content} || 'NULL'; } $p->parse($data); $p->eof; print Dumper $p->{meta};

cheers

tachyon


In reply to Re: Critique/Test my first module MetaParser by tachyon
in thread Critique/Test my first module MetaParser by sulfericacid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.