Let's make use of DBI and DBD::CSV.

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) a +s 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 fi +eld 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: $@";

which (at least for me on Windows 10) yields

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

In reply to Re: storing a file in 2d array by clueless newbie
in thread storing a file in 2d array by shabird

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.