Perl warn Function
This function prints the value of LIST to STDERR. Basically the same as the die function except that no call is made to the exit and no exception is raised within an eval statement. This can be useful to raise an error without causing the script to terminate prematurely.
If the variable $@ contains a value (from a previous eval call) and LIST is empty, then the value of $@ is printed with .\t.caught. appended to the end. If both $@ and LIST are empty, then .Warning: Something.s wrong. is printed.
Following is the simple syntax for this function −
This function does not return any value.
Following is the example code showing its basic usage −
#!/usr/bin/perl -w warn("Unable to calculate value, using defaults instead.\n");
When above code is executed, it produces the following result −
Unable to calculate value, using defaults instead