in reply to how to extract data from an array using a condition

The DBI code is also fairly simple...You have to set the field separator to be tab instead of the comma default. The easiest way is to treat each file as a separate table, below the file "patients" is the table with the data. There is a fair amount to learn about SQL and the DBI if these are completely new topics. This approach is the most extensible but it is also the most work.
#!/usr/bin/perl -w use strict; use DBI; # csv_sep_char=\t means tab separated, default is a comma of course my $dbh = DBI->connect("DBI:CSV:csv_sep_char=\t;RaiseError=1") or die "Cannot connect: " . $DBI::errstr; my $sth = $dbh->prepare("SELECT * FROM patients WHERE bmi>24 AND bp>135 AND age<30"); $sth->execute(); while (my $row = $sth->fetchrow_arrayref()) { print "@$row\n"; } __END__ Prints: Jane 50 23 200 Joe 30 22 140 File:patients contains tab separation in real file, my editor converts them to spaces here: name bmi age bp Jane 50 23 200 Bob 25 55 120 Norm 28 30 136 Joe 30 22 140 Ben 24 85 110
Now of course, if this is a "one off" thing, Excel is capable of importing this tab delimited file and the query tool would get you a result set too.