Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Shorten a filePrint a picture record (Berikutnya)
Input and output functions

Print debugging info

Daftar Isi

  • warn LIST

    Prints the value of LIST to STDERR. If the last element of LIST doesnot end in a newline, it appends the same file/line number text as diedoes.

    If the output is empty and $@ already contains a value (typically from aprevious eval) that value is used after appending "\t...caught"to $@. This is useful for staying almost, but not entirely similar todie.

    If $@ is empty then the string "Warning: Something's wrong" is used.

    No message is printed if there is a $SIG{__WARN__} handlerinstalled. It is the handler's responsibility to deal with the messageas it sees fit (like, for instance, converting it into a die). Mosthandlers must therefore arrange to actually display thewarnings that they are not prepared to deal with, by calling warnagain in the handler. Note that this is quite safe and will notproduce an endless loop, since __WARN__ hooks are not called frominside one.

    You will find this behavior is slightly different from that of$SIG{__DIE__} handlers (which don't suppress the error text, but caninstead call die again to change it).

    Using a __WARN__ handler provides a powerful way to silence allwarnings (even the so-called mandatory ones). An example:

    1. # wipe out *all* compile-time warnings
    2. BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } }
    3. my $foo = 10;
    4. my $foo = 20; # no warning about duplicate my $foo,
    5. # but hey, you asked for it!
    6. # no compile-time or run-time warnings before here
    7. $DOWARN = 1;
    8. # run-time warnings enabled after here
    9. warn "\$foo is alive and $foo!"; # does show up

    See perlvar for details on setting %SIG entries and for moreexamples. See the Carp module for other kinds of warnings using itscarp() and cluck() functions.

 
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) Shorten a filePrint a picture record (Berikutnya)