Can /warnings::warn/ be used with only standard warnings categories
(not a module-custom cat)?
warnings::warn() dies unless warnings::register() was previously called,
but if the package does not wish to create any new warnings categories
then warnings::register should not be used, I assume.
|#!/usr/bin/env perl||
||
||package Foo;||
||sub import {||
|| use Carp;||
|| use warnings;||
|| my $enabled = warnings::enabled("deprecated");||
||
|| warnings::warn "This is deprecated" if $enabled; #dies with "package
'Foo' not registered for warnings"||||
||}||
||
||package main;||
||
||use warnings FATAL => 'all';||
||Foo->import("blah");||
||die "SHOULD NOT GET HERE (due to FATAL => all)";||
|
(not a module-custom cat)?
warnings::warn() dies unless warnings::register() was previously called,
but if the package does not wish to create any new warnings categories
then warnings::register should not be used, I assume.
|#!/usr/bin/env perl||
||
||package Foo;||
||sub import {||
|| use Carp;||
|| use warnings;||
|| my $enabled = warnings::enabled("deprecated");||
||
|| warnings::warn "This is deprecated" if $enabled; #dies with "package
'Foo' not registered for warnings"||||
||}||
||
||package main;||
||
||use warnings FATAL => 'all';||
||Foo->import("blah");||
||die "SHOULD NOT GET HERE (due to FATAL => all)";||
|