It occurs to me that you might be thinking of the solution to this problem in terms of operating system calls, rather than the way that Perl shines when solving this kind of problem. Perl is great for gathering filenames via grep, and even has modules for processing tarfiles and gzips (Archive::TarGzip, for one).

Maybe you could restate your problem in terms of the basic inputs and outputs, and then we'll help you with the Perlish way to do it.