in reply to Diamond errors
If you want the errors to be kept till after the loop, maybe try a $SIG{"__WARN__"} handler
d:\temp>perl -e"$SIG{"__WARN__"} = sub {push @err,$_[0]; print STDERR +$_[0]}; while(<>) {1};print qq<---\n @err>" file1 file2 file3 Can't open file1: No such file or directory at -e line 1. Can't open file2: No such file or directory at -e line 1. Can't open file3: No such file or directory at -e line 1. --- Can't open file1: No such file or directory at -e line 1. Can't open file2: No such file or directory at -e line 1. Can't open file3: No such file or directory at -e line 1. d:\temp>
This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread
you can also only record the filename by pushing $ARGV instead and control what the user sees.
furthermore you can scope the handler with local tightly around the relevant code
{ local $SIG{"__WARN__"}= sub {...}; while(<>){...} }
Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery
|
|---|