develooper Front page | perl.perl5.porters | Postings from January 2020

Re: 'use warnings' with exceptions

Thread Previous | Thread Next
David Cantrell
January 27, 2020 17:26
Re: 'use warnings' with exceptions
Message ID:
On Mon, Jan 27, 2020 at 10:40:19AM -0500, Dan Book wrote:
> On Mon, Jan 27, 2020 at 6:19 AM David Cantrell <>
> wrote:
> >   use warnings qw(-foo -bar);
> > to mean "import all the warnings except foo and bar". But it seems not
> > to be. Before I put fingers to keyboard and implement it does anyone
> > think it's a terrible idea?
> I like the idea, but I think first we need to resolve the question, all
> warnings or default warnings? (It's already a difficulty to add new
> warnings without making them default, let's not make it harder...)

What I wanted was for 'use warnings qw(-foo)' to mean the same as plain
old 'use warnings' but without 'foo'.

If the user says 'use warnings qw(foo -bar)' then that should I think
just turn on the 'foo' warning, and turn off the '-bar' warning.

If you've already got some warnings turned on but then in some
restricted scope want to turn 'foo' warnings off - that's what
'no warnings qw(foo)' is for.

So, this:

  use warnings qw(-foo -bar);

would be equivalent to:

  use warnings qw(all);
  no warnings qw(foo bar);

and this:

  use warnings qw(foo bar -baz -barf);

would be equivalent to:

  use warnings qw(foo bar);
  no warnings qw(baz barf);

... and that's what I implemented while waiting for tests to run: 

David Cantrell | Hero of the Information Age

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About