Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: log::log4perl capture warnings

by Laurent_R (Canon)
on Apr 29, 2015 at 20:16 UTC ( [id://1125167]=note: print w/replies, xml ) Need Help??


in reply to log::log4perl capture warnings

Please note that "Illegal division by zero" is not a warning but an exception, i.e. a fatal error. With a warning, the script will usually print the warning and continue to execute. Not so with "Illegal division by zero": the program will immediately cease to execute (unless you trap the exception). Consider this one-liner:
$ perl -e 'use strict; use warnings; my $c = 1/0; print "we get there\ +n";' Illegal division by zero at -e line 1. $
As you can see, the final statement is not executed, we don't even "get there".

Compare to this, where the error is trapped within an eval block:

$ perl -e 'use strict; use warnings; eval {my $c = 1/0;}; print "we +get there but got the following problem:\n $@ \n";' we get there but got the following problem: Illegal division by zero at -e line 1. $
Here, the program does not die, but checking the value of the $@ makes it possible for the developer to possibly take other actions than just dying (for example if something can be recovered, so that the error should not be fatal).

Je suis Charlie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1125167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found