A Perl module which switches off some warnings

This example module shows how to create a Perl module which loads signatures without the experimental warning and without having to write

no warnings 'experimental::signatures';

each time.

package NoSigWarn;
require Exporter;
our @ISA = qw(Exporter);
use warnings;

no warnings qw(experimental::signatures);
use feature qw(signatures);

sub import
    warnings->import ();
    warnings->unimport (qw(experimental::signatures));
    feature->import ('signatures');
    NoSigWarn->export_to_level (1);



Here the line warnings->unimport is equivalent to no warnings.

It can then be used like this:

use warnings;
use strict;
use FindBin '$Bin';
use lib $Bin;
use NoSigWarn;

sub hw($hello, $world)
    print "$hello $world\n";

hw ('hey-ho', 'peeps');


Copyright © Ben Bullock 2009-2023. All rights reserved. For comments, questions, and corrections, please email Ben Bullock (benkasminbullock@gmail.com) or use the discussion group at Google Groups. / Privacy / Disclaimer