in reply to CGI Table Column Selection

Connecting and disconnecting to the same database in the same script is silly ... you could go to the trouble of creating a Singleton, or you could simply connect to the database at the beginning and use $dbh as a global variable (some globals are good). Also, you can cut back on having to worry about database errors if you turn on RaiseError:
my $dbh = DBI->connect($dsn,$user,$pass,{RaiseError=>1});
Now DBI will die with $DBI::errstr for you.

Onward ... so, what you want is to select the rows whose fields ALL do not contain the token 'NA'. You can do this with SQL, if you don't mind a lot of appended comparisons:

SELECT MID,Mname FROM ML_Lists WHERE MID != 'NA' OR ML_Lists != 'NA'
There, no Perl code needed. But, since you asked ... here is one way to do it:
my @list; my $sth = $dbh->selectall_arrayref('select MID,Mname from ML_Lists'); for (@$sth) { push @list,$_ if grep(/^NA$/,@$_) != @$_; }
grep is used to find the number of fields that contain only the string 'NA' and that number is compared to the total number of rows (@$_ in this context) to see if they are the same. If they are not, then the row contains at least one field that does not have the value 'NA', and that row is pushed to @list. (Personally, i'd rather let the database handle this job, not Perl.)

Hope this helps, and if you haven't already, then please check out The fine art of database programming. Purchasing Programming the Perl DBI isn't a bad idea either (considering you read it, of course). Hope this helps. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)