#!/usr/bin/env perl use feature 'say'; use feature 'signatures'; # Switch all warnings *off*, and only some warnings *on* explicitly: no warnings; use warnings qw( void once experimental::signatures ); # Let's check whether the warnings are generated: # Checking 'void' warnings: "hello"; # Results in a 'Useless use of a constant ("hello") in void context' # warning (as expected). # Checking 'once' warnings: $x = 1; # Results in a 'Name "main::x" used only once: possible typo' warning # (as expected). # Checking 'experimental::signatures' warnings: sub foo( $param ) { say "foo( $param )" } # Results in a 'The signatures feature is experimental' warning # (as expected; no warning in perl v5.36 since there, the feature is # not experimental anymore.) # Let's see what 'warnings::enabled' returns, # and let 'warnings::warnif' print an own warning for each enabled # category (and they should all be enabled!): for my $category ( qw( void once experimental::signatures ) ) { say "warnings::enabled( $category ) returns ", warnings::enabled( $category ) ? "TRUE" : "**FALSE**", "."; warnings::warnif( $category, "my own warning for $category" ); } # Prints this: # warnings::enabled( void ) returns **FALSE**. # warnings::enabled( once ) returns **FALSE**. # warnings::enabled( experimental::signatures ) returns TRUE. # my own warning for experimental::signatures at [...] # # But no output for the 'void' or 'once' categories. 1;