in reply to Trapping Errors from XML::RSS

You want to use the block form of eval. Here's the quick and dirty:

next if ( ! eval { $rss->parse($url2parse); 1 } );

A slightly more involved example:

use English qw( -no_match_vars ); eval { $rss->parse($url2parse); }; if ( $EVAL_ERROR ) { my $err = $EVAL_ERROR; if ( $err =~ /bad feed or whatever/ ) { next; } else { # some error you weren't expecting die $err; # rethrow it } }

If you don't use English, $EVAL_ERROR is known as $@. See perlvar.

Replies are listed 'Best First'.
Re^2: Trapping Errors from XML::RSS
by 3dkiwi (Novice) on Jun 19, 2007 at 04:03 UTC
    Kyle
    Your quick and dirty example hit the spot. I will pad it out a bit for my application. And again thanks to you and Zaxo for the tips.
    3d
    PS if you want to see my other coding attempts check out http://www.pyenet.co.nz/pro-pro.html
Re^2: Trapping Errors from XML::RSS
by 3dkiwi (Novice) on Jun 19, 2007 at 03:44 UTC
    Kyle
    Sounds like the solution. Many thanks for the quick response. Will give it a try and let you know the results.
    Again thanks
    3d