Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

warn

Issues a warning message to STDERR without terminating the program.

Prints the argument to STDERR. If the string does not end with a newline, Perl appends at FILE line LINE.

If $SIG{__WARN__} is set to a code reference, that handler is called with the warning message as its sole argument instead of printing to STDERR. The handler runs in void context and its return value is discarded.

Synopsis

warn "something looks wrong";
warn "problem at $file line $line\n";
warn $object;

Implementation Notes

perl5 (pp_sys.c:537): mark-based list op. If SP - MARK > 1, joins all args with “” via do_join into TARG. If SP == MARK (no args), uses “”. Single arg: uses TOPs directly. Then mess_sv for location if no trailing \n, write to stderr.

See Also

PP runtime: warn | die, Carp