develooper Front page | perl.perl5.porters | Postings from August 2023

warnings::warn using only standard warnings categories?

Thread Next
Jim Avera
August 16, 2023 18:55
warnings::warn using only standard warnings categories?
Message ID:
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';||
||die "SHOULD NOT GET HERE (due to FATAL => all)";||

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About