in reply to how to extract data from an array using a condition
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.#!/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
|
|---|