in reply to Best way to replace 'die' with 'warn'
So, what to do about it?
The most bare-bones way to deal with it would be
You could go even more minimal witheval { weather_subroutine(); } or do { warn $@; }; # <-- Note trailing semicolon; it *does* matter
but that has some weird edge cases where $@ can get messed up, so the eval { } or do { }; construct is more reliable.eval { weather_subroutine(); } warn $@ if $@;
If you want something more robust and/or with more familiar spellings, take a look at TryCatch or Try::Tiny. (The Try::Tiny synopsis shows how to use it to turn an exception into a warning, so you could even lift that example straight out of the docs.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to replace 'die' with 'warn'
by puterboy (Scribe) on Dec 06, 2009 at 10:56 UTC | |
|
Re^2: Best way to replace 'die' with 'warn'
by puterboy (Scribe) on Dec 06, 2009 at 18:13 UTC |