Define sub extract_zip defined array with dir path foreach path define $zip object using Archive::Zip Read members of all archive. foreach member condition apply if $member =~ /input\.txt/ $extractFilename = "tmp/output.txt"; extract file with memberOrZipName => $member,name => $extractFilename return $extractFilename which supposed to consist of all content from all "input.txt" file.