use File::Temp (); use Archive::Extract (); for my $gz ( @ARGV ) { my $tmp = File::Temp->new(); my $ae = Archive::Extract->new( archive => $gz ); my $ok = $ae->extract( to => $tmp->filename ); die $ae->error unless $ok; # do what you want to the uncompressed content in the # file named $tmp->filename ... # at the end of the scope, $tmp vanishes }