=over =item warn LIST X X X Prints the value of LIST to STDERR. If the last element of LIST does not end in a newline, it appends the same file/line number text as L|/die LIST> does. If the output is empty and L|perlvar/$@> already contains a value (typically from a previous eval) that value is used after appending C<"\t...caught"> to L|perlvar/$@>. This is useful for staying almost, but not entirely similar to L|/die LIST>. If L|perlvar/$@> is empty, then the string C<"Warning: Something's wrong"> is used. No message is printed if there is a L|perlvar/%SIG> handler installed. It is the handler's responsibility to deal with the message as it sees fit (like, for instance, converting it into a L|/die LIST>). Most handlers must therefore arrange to actually display the warnings that they are not prepared to deal with, by calling L|/warn LIST> again in the handler. Note that this is quite safe and will not produce an endless loop, since C<__WARN__> hooks are not called from inside one. You will find this behavior is slightly different from that of L|perlvar/%SIG> handlers (which don't suppress the error text, but can instead call L|/die LIST> again to change it). Using a C<__WARN__> handler provides a powerful way to silence all warnings (even the so-called mandatory ones). An example: # wipe out *all* compile-time warnings BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN } } my $foo = 10; my $foo = 20; # no warning about duplicate my $foo, # but hey, you asked for it! # no compile-time or run-time warnings before here $DOWARN = 1; # run-time warnings enabled after here warn "\$foo is alive and $foo!"; # does show up See L for details on setting L|perlvar/%SIG> entries and for more examples. See the L module for other kinds of warnings using its C and C functions. =back