http://qs321.pair.com?node_id=918009

bdimych has asked for the wisdom of the Perl Monks concerning the following question:

hi
in bash there is "set -e" feature
is there something similar in perl?
  • Comment on is it possible to make perl die on error automatically?

Replies are listed 'Best First'.
Re: is it possible to make perl die on error automatically?
by Corion (Patriarch) on Aug 02, 2011 at 10:22 UTC
Re: is it possible to make perl die on error automatically?
by davido (Cardinal) on Aug 02, 2011 at 17:20 UTC

    • autodie for IO operations.
    • RaiseError with DBI.
    • XML::Parser: A die call is thrown if a parse error occurs.
    • XML::LibXML will throw an exception if a parsing error occurs.
    • warnings can be elevated to fatals. See perllexwarn.
    • strict will make some risky behaviors an error that won't allow execution to begin.
    • perlrun: Taint mode will throw an exception if it catches you doing unsafe things with tainted input.
    • You can, of course, pepper your code with or die $! or or die "Message..."

    There are plenty of other possibilities too, if we knew what you're after.


    Dave

Re: is it possible to make perl die on error automatically?
by JavaFan (Canon) on Aug 02, 2011 at 15:59 UTC
    Uhm, the default for Perl is to die on error. So, I'm not sure what you are asking.