in reply to Grouping fields (mimic Excel 'AutoFilter' functionality)
However, in general, if you want to tally categories in Perl, the best way is to use a hash, as in:
In your case, you would search the input line for a bargain reference, and then increase the value of the entry in the hash corresponding to that bargain reference. Thanks to the magic of autovivifications, the entry for any new bargain references are automatically created for you.use strict; use Data::Dumper; my %hash; (chomp, $hash{$_}++) for <DATA>; print Dumper(\%hash); __DATA__ camel flea camel dog frog jabberwock frog camel __END__ $VAR1 = { 'flea' => 1, 'camel' => 3, 'dog' => 1, 'jabberwock' => 1, 'frog' => 2 };
CU
Robartes-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Grouping fields (mimic Excel 'AutoFilter' functionality)
by Anonymous Monk on Nov 21, 2002 at 14:23 UTC |