tutorials:perl:find_empty_file.2.pl
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:perl:find_empty_file.2.pl [2017/04/12 14:36] – removed chkuo | tutorials:perl:find_empty_file.2.pl [2017/04/12 14:45] (current) – chkuo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <file perl find_empty_file.2.pl> | ||
| + | # | ||
| + | my $script_name = ' | ||
| + | |||
| + | # Chih-Horng Kuo < | ||
| + | # find empty files in the " | ||
| + | # use the " | ||
| + | # set " | ||
| + | # v2 2010/07/12 | ||
| + | # style change | ||
| + | # v1 2007/05/25 | ||
| + | |||
| + | use strict; | ||
| + | use warnings; | ||
| + | |||
| + | use Getopt:: | ||
| + | |||
| + | my $in_dir; | ||
| + | my $regex; | ||
| + | my $opt_rm; | ||
| + | my $verbose; | ||
| + | my $debug; | ||
| + | |||
| + | GetOptions( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ); | ||
| + | |||
| + | my $count_in | ||
| + | my $count_non_empty = 0; | ||
| + | my $count_empty | ||
| + | |||
| + | # get list of in_files | ||
| + | chdir $in_dir or die " | ||
| + | my @in_files = glob " | ||
| + | foreach my $in_file (@in_files) { | ||
| + | $count_in++; | ||
| + | if ( -z $in_file ) { | ||
| + | $count_empty++; | ||
| + | print " | ||
| + | unlink $in_file if ($opt_rm); | ||
| + | } | ||
| + | else { | ||
| + | $count_non_empty++; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | print " | ||
| + | print " | ||
| + | print " | ||
| + | |||
| + | exit(0); | ||
| + | </ | ||
tutorials/perl/find_empty_file.2.pl.1491978995.txt.gz · Last modified: by chkuo