better error messages
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 7 Jul 2023 18:32:00 +0000 (20:32 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 7 Jul 2023 18:32:00 +0000 (20:32 +0200)
p.pl

diff --git a/p.pl b/p.pl
index 7693e59..61f5bcb 100755 (executable)
--- a/p.pl
+++ b/p.pl
@@ -39,16 +39,21 @@ while(<$fh>) {
        warn "#[ $_ ]\n" if $debug;
 
        if ( ! $last_id || $last_id ne $v[0] ) {
-               $file2 = glob 'originals_2023-07-07/' . $v[0] . '*.csv';
+               my $patt = 'originals_2023-07-07/' . $v[0] . '*.csv';
+               $file2 = glob $patt;
+               $file2 ||= glob 'originals_2023-07-07/' . $v[0] . '*.csv';
 
-               next unless $file2; # FIXME
+               if ( ! defined $file2 ) {
+                       warn "SKIP ERROR: $patt glob didn't find anything for v[0]=$v[0] [$_]";
+                       next;
+               }
 
-               if ( ! -e $file2 ) {
-                       warn "ERROR: $file2 doesn't exist, SKIPPING";
+               if ( ! -r $file2 ) {
+                       warn "ERROR: $patt glob file $file2 not readable: $! SKIPPING [$_]";
                        next;
                }
 
-               warn "# file2 $file2 [$v[0]]" if $debug;
+               warn "# file2 $file2 [$v[0]]";
                open($fh2, '<', $file2);
                $last_id = $v[0];
                @h2 = ();