|P is for Practical|
Selectively importing warningsby coolmichael (Deacon)
|on Nov 15, 2013 at 22:34 UTC||Need Help??|
coolmichael has asked for the
wisdom of the Perl Monks concerning the following question:
Following in Ovid's footsteps, I'm trying to remove boilerplate from my code. I'm generally happy with the result, but for warnings.
I have a module with an import method. It's only purpose is to enable strict and warnings and a few other pragmas. But, I don't want it to enable all warnings, and this is where I'm a bit stumped.
The problem is 'warnings'->unimport::out_of($target, 'experimental::smartmatch'); turns off all warnings, not just the one I want.
unimport::out_of() is calling warnings->unimport('experimental::smartmatch'); - which I think is the same as calling no warnings 'experimental::smartmatch';. But it isn't working.
So how do enable warnings (except one) via an import sub?
update: This is Perl 5.18.1. I also fixed some formatting.