Were I trying to tout the advantages of Perl to a maintainance programmer who had been around the block, I would not put in comments that they would be sure to recognize as maintainance pitfalls! Instead I would go the other way:
#! /usr/bin/perl -w
use strict;
# Create a frequency count of all words in all input files
my %freq_count;
while (defined(my $line = <>)) {
while ($line =~ /(\w+)/g) {
$freq_count{$1}++;
}
}
# Print the frequency summary.
foreach my $word (sort keys %freq_count) {
print "$word:\t$freq_count{$word}\n";
}
There. The looping constructs are all readily explainable, there are no hidden uses of $_, and no comments that will become wrong with time. I also removed a bug in the code that you wrote (which you copied unchanged from
eduardo).
Kudos to the first person to figure out what the bug is.