Perl Dog Perl Dog - 1 year ago 74
Perl Question

Is there a difference between "use warnings;" and "use warnings 'all';"?

I have the habit of starting each and every of my scripts with

use strict;
use warnings;

But some of the high-rep fellows here recommend

use warnings 'all';

If I understood them right, the latter is even better than the first. So I read through the docs and found

All warnings are enabled in a block by either of these:

use warnings;
use warnings 'all';

Even the Camel Book says nothing different:

use warnings; # same as importing "all"


  • is there a difference, or

  • is it just more future-proof (in case future versions of Perl issue warnings we aren't aware of right now and
    use warnings;
    won't catch), or

  • is it just another habit, like e.g.
    ps -ef
    ps aux
    ? Some people use this while others prefer the other.

Answer Source


use warnings;

is equivalent to

use warnings 'all';

However, there has been talk on perl5porters of changing it to mean

use warnings 'default';

New "less-critical" warnings would be added to the "all" category but not shown by default. Since it seems this change is seriously being considered, it's safer to use warnings 'all'; explicitly.

Previous discussions on p5p:

RFC: Support for new warning categories outside of "all"

I've added support for new warning categories outside of "all" to blead

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download