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 | |
|
Re^2: Trapping Errors from XML::RSS
by 3dkiwi (Novice) on Jun 19, 2007 at 03:44 UTC |