in reply to Printing Warning Messages Into a File
Warning messages don't go to STDOUT, and the redirection you're using only redirects STDOUT to a file. This is typically a good thing, since it's nice to be able to have all of your prints, for example, be saved in a file while your warnings are not.
You can either use the shell to redirect such warnings to a file, as others have explained, or in your code you can set up a signal handler for warnings:
open WARN, '> warnings.txt' or die ("Cannot write warnings.txt: $!"); local $SIG{__WARN__} = sub { print WARN @_,"\n" };
Or, even easier IMO, redirect STDERR, so that everything written there (which includes warnings) will be written to a file.
open WARN, '> warnings.txt' or die ("Cannot write warnings.txt: $!"); *STDERR = *WARN;
|
|---|