title: perl: split data into columns, choose certain columns, load column 1 as keys to a hash, load column 2 as values in hash
body: <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  
  # (1) program reads file
  # (2) uses the split fxn to split the columns
  # (3) loads the IDs that begin with FBgn from the 1st column as keys to a hash
  # (4) loads the gene symbol from the second column as the value in each hash entry
  
  my $infile = "fb_synonym_fb_2013_05.tsv";
  
  open( FILE, "&lt;", $infile )
      or die "Cannot open file $!";
  
  my @data = &lt;FILE&gt;;
  
  foreach my $line (@data) {
      my @column = split( /\s+/, $line );
      #print $column[0],"\n";
      my $columnID = $column[0];
          foreach ( my $columnID ) {
              while ( $columnID =~ /(^FBgn\d+)/ ) {
                  my $ID = $1;
                  print $ID, "\n";
              }
          }
   }
  </code></pre>
  
  <p>I try to run the code but it says that $columnID is an uninitialized value. I'm stuck at this point. I need to select the columns that begin with "FBgn"</p>
  
  <p>input:
  data file is very large so here is a selection</p>
  
  <pre><code>##primary_FBid current_symbol current_fullname fullname_synonym(s) symbol_synonym(s)
  FBtr0000004 Ecol\lacZ[svp-3]RA      lacZ[svp-3]RA
  FBtr0000005 Ecol\lacZ[hkb-5953]RA       lacZ[5953]RA,lacZ[hkb-5953]RA,hkb-  lacZ,5953
  FBtr0000007 Mab4A11[+]R2.1          
  FBtr0000009 Ecol\lacZ[betaTub56D.AS1]RA lacZ[betaTub56D.AS1]RA
  FBtr0000010 Ecol\lacZ[betaTub56D.AS2]RA lacZ[betaTub56D.AS2]RA
  FBtr0000011 Ecol\lacZ[betaTub56D.AS3]RA lacZ[betaTub56D.AS3]RA
  FBtr0000012 Ecol\lacZ[betaTub56D.NN]RA  lacZ[betaTub56D.NN]RA
  FBtr0000013 Ecol\lacZ[betaTub56D.NC]RA  lacZ[betaTub56D.NC]RA
  FBtr0000014 Ecol\lacZ[betaTub56D.CP]RA  lacZ[betaTub56D.CP]RA
  FBtr0000015 Ecol\lacZ[betaTub56D.ACO]RA lacZ[betaTub56D.ACO]RA
  FBtr0000016 Ecol\lacZ[betaTub56D.AC3]RA lacZ[betaTub56D.AC3]RA
  </code></pre>