I have a script that needs to be able to operate on either a plain text file or a gzipped version of that file. If the file is not gzipped, the file will be opened as follows:
open(FOO, $foo) || die("ERROR: Unable to open file $foo for read: $!")
+;
If the file is gzipped, the file will be opened as follows:
open(FOO, "zcat $foo |") || die("ERROR: Unable to open gzipped file $f
+oo for read: $!");
How do I write a check to determine whether the file is gzipped or not? zcat errors out when called on non-gzipped files.