Someone here must be familiar with the Diaryland system. It's one of those weblog thing. Well, I was writing a script to have it shown to me when I startup, and thought that despite me being a novice it should be fairly easy. I've run into a hitch, though.
use strict; use warnings; use diagnostics; use HTML::TokeParser; use LWP::Simple; print &parse_diaryland('username', 'password'); sub parse_diaryland { my($username, $password); my($diary_url); my($parsee_man); my($html, $tag); my($body); $username = shift(); $password = shift(); $diary_url = "http://$username:$password\@$username.diaryland.com" +; # urls are in the form http://username:password@username.diaryla +nd.com $html = get($diary_url); print $html; $parsee_man = HTML::TokeParser->new(\$html); foreach $tag ($parsee_man->get_tag('TD')) { if ($tag->[1]{'align'} eq 'left' && $tag->[1]{'vAlign'} eq 'to +p') # fails here { my($secondtag); $secondtag = $parsee_man->get_tag(); if ($secondtag->[0] eq 'FONT') { $body = get_text('/FONT'); last(); # got the text body so quit loop } } } return($body); }
and we're matching this:
<TD align=left vAlign=top><FONT face="Verdana, Arial, Helvetica, sans- +serif" size=2>I This is the text body we wanna grab. foo, bar and angst. </FONT>
That fails with "use of uninitialised variable in string eq at line 30". I can vaguely make sense of this: the page we're getting has some TD tags earlier, and they lack the align and valign attributes, so that would be undefined. How can I fix this, though?

In reply to Diaryland parsing by Amoe

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.