I need to port some code from Python to Perl. The Python code makes simple use of the warnings module, e.g.
warnings.warn("Hey I'm a warning.")
I've been googling around quite a bit but it's unclear to me what the equivalent Perl idiom might be. How would a Perl programmer handle this?
To write a message to STDERR
, simply use the built-in warn
function.
warn "Hey I'm a warning.";
But you should also use Perl's warnings
module, as well as strict
because they turn on all kinds of useful compiler warnings and error checking for you.
Therefore, begin all your programs with
use strict;
use warnings;
warn "Hey I'm a warning.";
(You don't need the warnings
module to use the warn
function, though.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With