in reply to Grouping fields (mimic Excel 'AutoFilter' functionality)

rdfield has the right idea: databases are built for this kind of thing, so use them - it's all about using the best tool for the job.

However, in general, if you want to tally categories in Perl, the best way is to use a hash, as in:

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 };
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.

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

    Great - thanks a lot guys.

    One thing though, its not actually extracting from a Sybase database - the flex::SQL runs against a file which is mapped via F.trade_reference etc...

    So I don't have access to group_by or anything, as I am extracting directly from a .dat file...