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.
package Foo; # lots of use statements here. use Import::Into; sub import { my $target = caller; 'strict'->import::into($target); 'warnings'->import::into($target, qw(FATAL utf8)); if ($] >= 5.017011) { # THIS IS THE PROBLEM LINE 'warnings'->unimport::out_of($target, 'experimental::smartmatc +h'); } }
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.
In reply to Selectively importing warnings by coolmichael
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |