Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Perl pragma to control VMS-spe ...Warnings import function (Berikutnya)
Pragmas

Perl pragma to control optional warnings

Daftar Isi

NAME

warnings - Perl pragma to control optional warnings

SYNOPSIS

  1. use warnings;
  2. no warnings;
  3. use warnings "all";
  4. no warnings "all";
  5. use warnings::register;
  6. if (warnings::enabled()) {
  7. warnings::warn("some warning");
  8. }
  9. if (warnings::enabled("void")) {
  10. warnings::warn("void", "some warning");
  11. }
  12. if (warnings::enabled($object)) {
  13. warnings::warn($object, "some warning");
  14. }
  15. warnings::warnif("some warning");
  16. warnings::warnif("void", "some warning");
  17. warnings::warnif($object, "some warning");

DESCRIPTION

The warnings pragma is a replacement for the command line flag -w,but the pragma is limited to the enclosing block, while the flag is global.See perllexwarn for more information and the list of built-in warningcategories.

If no import list is supplied, all possible warnings are either enabledor disabled.

A number of functions are provided to assist module authors.

  • use warnings::register

    Creates a new warnings category with the same name as the package wherethe call to the pragma is used.

  • warnings::enabled()

    Use the warnings category with the same name as the current package.

    Return TRUE if that warnings category is enabled in the calling module.Otherwise returns FALSE.

  • warnings::enabled($category)

    Return TRUE if the warnings category, $category, is enabled in thecalling module.Otherwise returns FALSE.

  • warnings::enabled($object)

    Use the name of the class for the object reference, $object, as thewarnings category.

    Return TRUE if that warnings category is enabled in the first scopewhere the object is used.Otherwise returns FALSE.

  • warnings::fatal_enabled()

    Return TRUE if the warnings category with the same name as the currentpackage has been set to FATAL in the calling module.Otherwise returns FALSE.

  • warnings::fatal_enabled($category)

    Return TRUE if the warnings category $category has been set to FATAL inthe calling module.Otherwise returns FALSE.

  • warnings::fatal_enabled($object)

    Use the name of the class for the object reference, $object, as thewarnings category.

    Return TRUE if that warnings category has been set to FATAL in the firstscope where the object is used.Otherwise returns FALSE.

  • warnings::warn($message)

    Print $message to STDERR.

    Use the warnings category with the same name as the current package.

    If that warnings category has been set to "FATAL" in the calling modulethen die. Otherwise return.

  • warnings::warn($category, $message)

    Print $message to STDERR.

    If the warnings category, $category, has been set to "FATAL" in thecalling module then die. Otherwise return.

  • warnings::warn($object, $message)

    Print $message to STDERR.

    Use the name of the class for the object reference, $object, as thewarnings category.

    If that warnings category has been set to "FATAL" in the scope where $objectis first used then die. Otherwise return.

  • warnings::warnif($message)

    Equivalent to:

    1. if (warnings::enabled())
    2. { warnings::warn($message) }
  • warnings::warnif($category, $message)

    Equivalent to:

    1. if (warnings::enabled($category))
    2. { warnings::warn($category, $message) }
  • warnings::warnif($object, $message)

    Equivalent to:

    1. if (warnings::enabled($object))
    2. { warnings::warn($object, $message) }
  • warnings::register_categories(@names)

    This registers warning categories for the given names and is primarily foruse by the warnings::register pragma, for which see perllexwarn.

See Pragmatic Modules in perlmodlib and perllexwarn.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Perl pragma to control VMS-spe ...Warnings import function (Berikutnya)