my $ret = system("tar -cvf $tar_file @srcfiles"); if ( -e $tar_file){ system("compress -v $tar_file"); } @srcfiles is the array of filenames which matches the criteria