in reply to Best way to find patterns in csv file?

The best way depends on the patterns. Anyway I think you should first preprocess your patterns so that you don't have to compare the same values over and over again. Let's say you had just three columns and these four patterns:

p1: c1 = 5, c3 = 8
p2: c1 = 5, c3 = 4
p3: c2 = 4, c3 = 1
p4: c2 = 3, c3 = 5
so you would build a structure like this:
%patterns = ( 5 => { undef => { 8 => ['p1'], 4 => ['p2'] } }, undef => { 4 => { 1 => ['p3'] }, 3 => { 5 => ['p4'] } } );
and whenever you'd need to find all patterns that a match the current row you'd traverse this structure and find all leafs to which you can get through the keys matching the value of the columns or undefs. Eg. if the current row is 5,3,8 you'd first select both $patterns{5} and $patterns{undef()}, then after next step $patterns{5}{undef()} and $patterns{undef()}{3} and at last would end up with just @{$patterns{5}{undef()}{8}}=(p1). Not sure I make much sense, so let's try an example:
my @row = the data, without the record_id!; my @matching = (\%patterns); while (@row and @matching) { my $value = shift(@row); my @next_matching; foreach my $branch (@matching) { if (exists $branch->{$value}) { # there is a matching pattern if (ref($branch->{$value}) eq 'HASH') { # the pattern requ +ires some more values to match push @next_matching, $branch->{$value}; } else { # the pattern matched completely push @found_patterns, @{$branch->{$value}}; } } if (exists $branch->{undef()}) { # there is a patter that does +n't care about this value if (ref($branch->{undef()}) eq 'HASH') { # the pattern req +uires some more values to match push @next_matching, $branch->{undef()}; } else { # the pattern matched completely push @found_patterns, @{$branch->{undef()}}; } } } @matching = @next_matching; } # and now all the matching patterns are in @found_patterns # the code is untested and only intended as an example

Actually you may need to use a different value to mean "don't care" in the structure if some patterns require that some columns equal null and null != "".

I would use Text::CSV_XS to do the actual reading and parsing of the text file.

Jenda
We'd like to help you learn to help yourself
Look around you, all you see are sympathetic eyes
Stroll around the grounds until you feel at home
   -- P. Simon in Mrs. Robinson