in reply to How to test if a file is gzipped or not

If zcat throws an error then you know it's not gzipped:
open(FOO, "zcat $foo |") || open(FOO, $foo) || die("ERROR: Unable to o +pen file $foo for read: $!");