develooper Front page | perl.perl5.porters | Postings from October 2016

[perl #129947] warnings::warnif does not behave as documented

Thread Previous
Karen Etheridge
October 23, 2016 21:04
[perl #129947] warnings::warnif does not behave as documented
Message ID:
# New Ticket Created by  Karen Etheridge 
# Please include the string:  [perl #129947]
# in the subject line of all future correspondence about this issue. 
# <URL: >

The documentation of warnings::warnif (perldoc warnings) says:

        Equivalent to:

            if (warnings::enabled())
              { warnings::warn($message) }

    warnings::warnif($category, $message)
        Equivalent to:

            if (warnings::enabled($category))
              { warnings::warn($category, $message) }

But it clearly isn't. Notice the difference in location identified in the
warning (*somewhat* as if if Carp::shortmess was used, but actually more than
one stack frame can be skipped):

    use strict;
    use warnings;

	package Foo;

	sub foo {
	    warnings::warnif('deprecated', 'warning with warnif()');

	    warn 'warning with warn()' if warnings::enabled('deprecated'); 


    gives output:
    warning with warnif() at line 14.
    warning with warn() at line 10.

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