in reply to Re: What's happening to my $1?
in thread What's happening to my $1?
By the way, in your first piece of code, there is no need to initialize the hash elements to 0. This is Perl ;-)
Thanks, you're right, of course. However, I happen to hate empty if blocks.
Don't worry, it's just a personal thing ;-). So I re-wrote my original code (which I'll probably never use again since it's proved so fragile):
my %totals; while ( <DATA> ) { chomp; /(^[a-z].*$)/i or $totals{$1} += $_; }
Thanks again for the tip.
dave
|
---|