Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Perhaps eval (); should be eval { };?

    use XML::RSS;
    my $f = XML::RSS->new;
    eval { $f->parse( 'x' ); };
    print 'okay';
    • Unless you mis-transcribed, LTJake is right. What you're doing is "eval EXPR" which evaluates the expression normally, then assumes it's a string containing Perl code and evaluates that. What you want is "eval BLOCK" which runs the block of code, catching exceptions.
      • Yep, that's exactly what it is. The only mis-transcription was that I'd formatted it all pretty in my code just like it was a block, and it never once registered that hey, those are awfully rounded curly-braces. Not even when I left it all on one line in my rant. (And I guess that parse() must return a 1 or something equally harmless on success.)

        Bah, decongestants. This is why I'm not working on production code today. And clearly should not even be let near even the quick hack stuff, either.

        Thanks, g
    • You know, you'd think that when it choked on a semi-colon I put in there (when I added a hello-world just to make sure it was hitting that code on *working* feeds), it would have maybe sent up a red flag for me. But nooooo, I sez to myself, I sez, "Gee, I can't even type a working print statement today, I'm just making this worse" and reverted it all instead of thinking about it.

      Yyyeah. No more coding for me today.
  • You might want to try XML::Liberal and XML::Feed for your feed parsing needs.
    • XML::Feed is just an API-unification wrapper around XML::RSS and XML::Atom::Feed, innit? I'm using XML::Atom::Syndication::Feed instead, for reasons I can't quite remember just now, but, uh, I'm sure they were good ones at the time.

      XML::Liberal might help, though I assume it has the same issue XML::Twig (which I saw someone recommend as an alternative) has in that it's not RSS-specific, and this was supposed to be a quick and dirty hack to pull title, date, content, and link out of feeds... and I didn't