warn "1: $!\n"; my $compressed_size = -s $file; warn "1: $!\n"; open(my $sd_fh, "<$file") || die "bla: $!"; warn "1: $!\n"; warn "sd_fh: $sd_fh\n"; if($!) { warn "couldn't open image, skipping: $file: $!\n"; next; }; $ perl foo.pl sd.32497.sd 1: 1: 1: Inappropriate ioctl for device sd_fh: GLOB(0x604290) couldn't open image, skipping: sd.32497.sd: Inappropriate ioctl for device