| Next | Program Repair Shop | 60 |
354 foreach $filesz (sort { $b <=> $a } keys %names_by_size)
...
371 if ($filesz == 0) # skip files of zero length
372 {
373 print "$num_files_this_size files of size 0:\n ",
374 join ("\n ", @{$names_by_size{$filesz}}), "\n";
375 next;
376 }
377
Here we check each key to see if it is 0
Hash keys are unique
At most one key can possibly be 0
The whole point of hashes is to make it easy to find such a key
{ my $zeroes = delete $names_by_size{0};
if ($zeroes) {
print @$zeroes . " files of size 0:\n ",
join ("\n ", @$zeroes);
}
}
And we can remove this code from the loop
Any opportunity to simplify a three-page loop is one we should consider
| Next | ![]() |
Copyright © 2006 M. J. Dominus |