G'day bartender1382,

I had a look in Spreadsheet::Read but can't find the "If a file cannot be found ..." message you reported. Perhaps it's not an error message but private feedback from the module's author. Regardless, I have no context for the die() or what it's reporting.

Having said that, I suspect what you want is eval. Compare the following two short pieces of code and their output.

Here's the type of scenario I think you're dealing with:

#!/usr/bin/env perl use strict; use warnings; package Module::That::Dies; sub die_here { die "RIP Module::That::Dies" } package main; Module::That::Dies::die_here(); print "main continues ...\n";

Output:

RIP Module::That::Dies at ./pm_11143055_trap_mod_errors.pl line 8.

Here's a modification of that code to do what I think you want:

#!/usr/bin/env perl use strict; use warnings; package Module::That::Dies; sub die_here { die "RIP Module::That::Dies" } package main; eval { Module::That::Dies::die_here(); 1; } or do { warn "Error from Module::That::Dies:\n$@\n"; }; print "main continues ...\n";

Output:

Error from Module::That::Dies: RIP Module::That::Dies at ./pm_11143055_trap_mod_errors.pl line 8. main continues ...

If that's not what you want, please provide more context for the problem to help us to help you.

— Ken


In reply to Re: Can I catch a die from someone else's module? by kcott
in thread Can I catch a die from someone else's module? by bartender1382

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.