use strict; use warnings; use Text::CSV; my %lookup; my $csv = Text::CSV->new (); my $filename = 'DATA'; while () { next unless $csv->parse ($_); my @row = $csv->fields (); next unless @row >= 7; my $key = $row[0]; next if exists $lookup{$key} && $row[7] <= $lookup{$key}{max}; $lookup{$key} = {max => $row[7], line => $., file => $filename}; } print "Following maximums found:\n"; print "$_ = $lookup{$_}{max} in file $lookup{$_}{file}, line $lookup{$_}{line}\n" for sort keys %lookup; __DATA__ DOW,Sep,18,09:31:16,440,29,142,10148,4 Russell2000,Sep,18,09:31:16,440,29,142,10148,4 RussellComposite,Sep,18,09:31:16,440,29,142,10148,4 Russell1000,Sep,18,09:31:16,440,29,142,10148,4 SP500,Sep,18,09:31:16,440,29,142,10148,4 Russell2000,Sep,18,09:31:16,440,29,142,10120,4 SP500,Sep,18,09:31:16,440,29,142,10160,4 #### Following maximums found: DOW = 10148 in file DATA, line 1 Russell1000 = 10148 in file DATA, line 4 Russell2000 = 10148 in file DATA, line 2 RussellComposite = 10148 in file DATA, line 3 SP500 = 10160 in file DATA, line 7