How to not die

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using XML::RSS module to parse lots of RSS files in batch. However
if one of the RSS files has invalid format, then a die call is thrown
from the parser. Is there any way I can handle the die call, so that
the program can keep running by skipping the invalid RSS file?

Re: How to not die

Quoted text here. Click to load it

Wrap your code in a block eval() - not to be confused with a string eval().
eval() returns undef on failure, and you can check $@ for the message given
to die(). For instance:

    # Not a complete program, obviously...
    eval {
    } or {
        warn $@ if $@;


Cocoa programming in Perl:
Hire me! My resume:

Re: How to not die

Also sprach Sherm Pendley:

Quoted text here. Click to load it

Depending on do_something's return value, this might still execute the
or-branch. I'd rather write this as:

    eval {
    } or warn $@;
use bigint;

Site Timeline