In our app we have a common base module that enables strict, warnings and some other pragmas for every file that it used from. It also enables signatures and disables the warning about signatures being experimental:
sub import {
warnings->unimport('experimental::signatures');
feature->import('signatures');
}
When testing in CI with Perl 5.32 (which still considered signatures experimental) I still get a load of warnings about experimental because we loaded other modules like Moose or Test2::V0 after our base module.
use MyApp::Base; # initial setup, enables signatures
use Carp;
use Moose; # unconditionally enables experimental warnings again
Is there any way to permanently disable a specific warning regardless of other modules making use warnings in our scope?
I wanted to use our base class as first import in every code to allow all kinds of initial setup tasks. Do I really need to handcraft the order to move all Moose/Test2::V0/… imports above like this?
use Moose; # these must come first
use Test2::V0;
use MyApp::Base; # now we can run our common setup
use Carp; # now we can import other stuff, too
How is this handled in other projects with a common base class?
Since you apparently do have to "unimport" after loading libraries that re-enable those warnings, why not have another module that does only such final configuration, in this case the needed un-importing? Then that one is loaded last.
A simplest example
A program that uses it
This is indeed yet another module to load but having a final configuration step makes some sense. With time, other last-thing configuration needs may find it useful.