$file !~ m/^[\w-]+(\.[\w-]+)*$/ #### cns061206 #### sub zip { (my $cmd, my $dir) = @_[0,1]; my $count; if($cmd eq 'unzip') { foreach my $file (glob($dir . '/*.gz')){ # get only gzipped files if(system(($cmd, $file)) == 0) { $count++; } else { warn "Could not $cmd $file\n"; } } return $count; } elsif($cmd eq 'zip') { foreach my $file (glob($dir . '/*')) { next if $file =~ /\.gz$/; next if $file =~ /\.txt$/; next unless $file =~ /(\.\w+)+$/; # which will skip files without an extension if(system(($cmd, $file)) == 0){ $count++; } else { warn "Could not $cmd $file\n"; } } return $count; } else { warn "Unknown command $cmd\n"; } } #### foreach my $file (glob($dir . '/*')) { #### foreach my $file (glob($dir . '/*.gz')) #### my @list = glob($dir . '/*'); foreach my $file (@list) { #### my @list = glob($dir . '/*.gz'); foreach my $file (@list) {