As for the cat command, which returns an exit code other than 0 if at least one file in the list does not exist, but continuing its execution, I would also like the same behavior for the "perl" command, which while continuing its execution, unfortunately it does not return a non-0 exit code when encountering one or more missing files.
This solution provided by another topic Why is my Perl in-place script exiting with a zero exit code even though it's failing?:
perl -p -i -e 'BEGIN{ -f $ARGV[0] or die"no file" } s/foo/bar/' non-existent-file.txt
Correctly returns a non-0 exit code when a file is not found but does not continue executing for other files. Indeed this:
perl -p -i -e 'BEGIN{ -f $ARGV[0] or die"no file" } s/foo/bar/' non-existent-file.txt existent-file.txt
doesn't give the output of the second file but only the error for the first non-existent file.
How can I solve the problem?