in reply to archives etc

I expect you want a variation on a theme of ...
if(system('gzip', '-d', $file) == 0) { # it was a gzipped file } elsif(system('bzip2', '-d', $file) == 0) { # it was a bzipped file } ...
This relies on the standard Unixish behaviour of applications exiting with status zero if successful, non-zero otherwise. No doubt you could also do something similar with open()ing a pipe to gzip/bzip2/etc and if the open() fails, try the next one on your list.