I was just playing around with your++ script. It's very cool, but I have the following comments / suggestions:

  1. The line:

    die unless $response->is_success;

    Really should be:

    die ("Could not fetch the web page because: " . $response->status_line) unless $response->is_success; die ("Content type not text/xml. It was" . $response->content_type) unless ($response->content_type eq 'text/xml');

    Otherwise you aren't notified why a get() fails, and it allows the user to try parsing a non XML web page -- which leads to some humorous results.

  2. Why is it even necessary to pass in the URL for the newest nodes page? Your script doesn't look like it will work on any page besides the newest nodes page, so doing a shift (@_) for the URL seems useless. Why not just set my $url = "http://www.perlmonks.org/index.pl?node_id=30175"; and be done with it?
  3. Excellent work. I thoroughly enjoyed it. Also, not to nitpick, but why don't you put

    use strict; use warnings;

    at the top of your script? It runs with no problems under them, and it's good practice (plus I think it's a good idea to help any new monks seeing it to get in the habit of using them).

Good job again!


Want to support the EFF and FSF by buying cool stuff? Click here.

In reply to Re: Code for Perlmonks XML to RSS by Vautrin
in thread Code for Perlmonks XML to RSS by xdg

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.