John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

First, it appears that warnings::warn will always warn (write to standard error) and only uses the caller's warn setting to die vs. warn, not to not warn. While warnings::warnif will add the warning enable/disable.

However, what we really want, I think, is carp rather than a warn, respecting the caller's settings.

If you write

if (warnings::enabled()) { carp "check your argument"; }
that still does nothing about the possibility that the caller set that category to FATAL. Furthermore, there is warnings::enabled but no indication of FATAL! This seems to be an oversight.

So, how can we use the warnings features in a module to best effect? Does anybody really use it?

—John

Replies are listed 'Best First'.
Bad docs
by John M. Dlugosz (Monsignor) on Aug 08, 2002 at 02:59 UTC
    It looks like the actual implementation in warnings.pm uses carp/croak. The pod docs in the same file says
    =item warnings::warn($message) Print C<$message> to STDERR.
    which is presumably out of date. Will anyone do something about this? I'd be happy to edit the POD and send the changes back to someone who actually owns this file.

    —John