I would like to send a deprecation notice like
warnings::warnif( 'deprecated', 'function foo is deprecated' );
but I'd prefer to have it carp up so it reports to the caller and not where the actual warn is. Can I do this with carp
somehow?
I would like to send a deprecation notice like
warnings::warnif( 'deprecated', 'function foo is deprecated' );
but I'd prefer to have it carp up so it reports to the caller and not where the actual warn is. Can I do this with carp
somehow?
Have you tried it?
package Foo {
sub bar {
warnings::warnif(deprecated => 'Foo:bar is deprecated');
}
}
use warnings;
# no warnings 'deprecated'; # <-- uncomment this to disable the warning
Foo::bar(); # <-- this is line 9
This should say something like:
Foo::bar is deprecated at test.pl line 9.
In fact, looking at the warnings.pm source, it seems to use Carp.pm internally. Admittedly, the documentation for the warnings pragma itself could be clearer about this, but perllexwarn does make it pretty clear that this is how it's meant to be used.