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


in reply to Difference Between use warnings and use warnings FATAL => 'all'

The difference is in the way the script behaves after the warning is issued: with use warnings; the script continues as normal, but with use warnings FATAL => 'all'; (note the spelling: warnings must be plural here) the script dies immediately:

12:30 >perl -e "printf qq[%f\n], $x;" 0.000000 12:31 >perl -e "use warnings; printf qq[%f\n], $x;" Name "main::x" used only once: possible typo at -e line 1. Use of uninitialized value $x in printf at -e line 1. 0.000000 12:31 >perl -e "use warnings FATAL => 'all'; printf qq[%f\n], $x;" Name "main::x" used only once: possible typo at -e line 1. Use of uninitialized value $x in printf at -e line 1. 12:31 >

This is documented in perllexwarn#Fatal-Warnings.

As to why? Well, in a long script with a lot of output, it may be easy to overlook warnings when they are interlaced with other information. Forcing the script to die at the point where the warning is detected makes it easier to locate and identify the problem, and motivates the programmer to fix the warning earlier, rather than later! (There may be other reasons.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Difference Between use warnings and use warnings FATAL => 'all'
by Anonymous Monk on Dec 27, 2013 at 02:56 UTC