| Next | Program Repair Shop | 44 |
And what's the price for all this new functionality?
300 my $cmd = "find " . join (" ", @ARGV) . " -type f -print |";
301 # print "cmd = ", $cmd, "\n";
302
303 open (pipefd, $cmd);
304
305 my ($filecount) = 0; # count just for stats
306 while (<pipefd>)
307 {
308 chomp; # eat the trailing newline
309 # see the Camel book page 266 for hashes of arrays
310 push @{ $names_by_size{-s $_} }, $_;
311 # $filecount++; now handled in next loop
312 }
313
314 close (pipefd);
The price is that we have to get rid of 5 lines of code!
for (@ARGV) {
push @{ $names_by_size{-s $_} }, $_;
}
Final note: I sometimes like to:
chomp(@ARGV = <STDIN>) unless @ARGV;
| Next | ![]() |
Copyright © 2006 M. J. Dominus |