use strict; use warnings; use Data::Dumper; use DBI; use 5.01800; # Get a connect to the tables my $dbh=DBI->connect ("dbi:CSV:", undef, undef, { f_dir => "/Users/Desktop/", f_ext => ".txt/r", csv_sep_char => "\t", RaiseError => 1, }) or die "Cannot connect: $DBI::errstr"; eval { my $sth=$dbh->prepare( # We want a concatenation of ... from the file Gene.txt in /Users/Desktop qq{select concat(ProteinName,'; ',MF1,'; ',MF2,'; ',MF3) as whatever from Gene} ); $sth->execute(); # get the names of the fields returned by the select my $field_aref=$sth->{NAME}; # and dump them ... #warn Data::Dumper->Dump([\$field_aref],[qw(*field_aref)]),' '; # Get the selection one row at a time while (my $value_aref=$sth->fetchrow_arrayref()) { # dump the values from the select #warn Data::Dumper->Dump([\$value_aref],[qw(*value_aref)]),' '; # For simplicity we will make a hash where the keys are the field names and the values are the values of those fields my %_h; @_h{@$field_aref}=@$value_aref; # dump the hash to confirm all is what we expect #warn Data::Dumper->Dump([\%_h],[qw(*_h)]),' '; # since everything looks reasonable ... say $_h{whatever}; }; }; $@ and die "SQL database error: $@"; #### d:\scratch>perl 11116298.t GH1; Growth factor activity; Growth hormone receptor binding; Hormone activity POMC; G protein-coupled receptor binding; Hormone activity; Signaling receptor binding THRAP3; ATP binding Source; Nuclear receptor transcription coactivator activity; Phosphoprotein binding