in reply to Re: Efficiency in maintenance coding...
in thread Efficiency in maintenance coding...
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).#! /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"; }
Kudos to the first person to figure out what the bug is.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re(3): Efficiency in maintenance coding...
by FoxtrotUniform (Prior) on Nov 15, 2001 at 02:58 UTC | |
by tilly (Archbishop) on Nov 15, 2001 at 03:05 UTC | |
by tye (Sage) on Nov 15, 2001 at 03:22 UTC | |
by tilly (Archbishop) on Nov 15, 2001 at 04:03 UTC | |
Re (tilly) 3: Efficiency in maintenance coding...
by jynx (Priest) on Nov 15, 2001 at 04:26 UTC | |
by tilly (Archbishop) on Nov 15, 2001 at 04:55 UTC | |
by tye (Sage) on Nov 15, 2001 at 04:45 UTC |