in reply to #!/usr/bin/perl -w and use warnings;

This is discussed in warnings and perllexwarn; from the former:

The "warnings" pragma is a replacement for the command line flag "-w", but the pragma is limited to the enclosing block, while the flag is global.

the lowliest monk

  • Comment on Re: #!/usr/bin/perl -w and use warnings;

Replies are listed 'Best First'.
Re^2: #!/usr/bin/perl -w and use warnings;
by ghenry (Vicar) on Apr 23, 2005 at 13:51 UTC

    Yes, I never thought of that, in that it would be useful to only have warnings for some sections, but the "-w" would be good to check other people modules.

    Do I understand that correctly?

    Walking the road to enlightenment... I found a penguin and a camel on the way.....
    Fancy a yourname@perl.me.uk? Just ask!!!

      The -w flag won't help you if the module's author explicitly turned warnings off. (I've run into this problem when a module's author turns off all warnings in a block, instead of selectively turning off a particular warning.) E.g.

      % perl -wle 'use warnings; { no warnings; $x == 1 } print "ok"' ok % perl -Wle 'use warnings; { no warnings; $x == 1 } print "ok"' Useless use of numeric eq (==) in void context at -e line 1. Name "main::x" used only once: possible typo at -e line 1. Use of uninitialized value in numeric eq (==) at -e line 1. ok

      Update: Clarified the original reply.

      the lowliest monk