Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Diamond errors

by LanX (Saint)
on Jan 21, 2023 at 18:42 UTC ( [id://11149750]=note: print w/replies, xml ) Need Help??


in reply to Diamond errors

> However, after the loop, there doesn't seem to be a way for the program to detect that a file wasn't processed

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149750]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found