I don't imagine you pick up all that much extra speed by reading the whole 
file into an array first (anyone?).

I would do something like

open(ACCS, "Accession.txt") || die "blah";
my %values;
while(<ACCS>)
         {
         chomp $_;
         my($col1, $col2) = split(/\t/, $_); # you better be sure that 
there are only two cols or you'll lose data this way --
                                         #either add error checking or 
throw it all into an array and then grab the values you want
         # then, since you have two cols, you probably want to do something 
like throw the thing into a hash
         $values{$col1} = $col2;
         # though you may want to do something totally different :)
         }
close ACCS
print "$_ => $values{$_}\n" foreach keys %values;

At 15:58 12.06.2001 +0100, you wrote:
>I am trying to read a quite large file (ca 13000 lines) directly into an
>array (for speed)
>like this
>
>open (ACCS, "C:\\Perl\\BioPerl-0.7\\Seqdata\\Accession.txt") or die "can't
>open Accessions file";
>@ets=<ACCS>;
>$ets_count=@ets;
>
>the actual data is a 2 column tab delimited file like:
>
>  <<...OLE_Obj...>>
>etc....
>I have been looking at the directions on using the split command in the
>"Perl -in a nutshell book", but really can't figure out how to split the
>@ets array into 2 separate arrays (say--@etsOrig + @etsRefSeq). I feel this
>is probably simple but err...not to me.
>
>Alternatively if you can tell me how to reference just the second part of
>the line  in a loop like e.g.
>for($i=0; $i < $ets_count; $i++)
>{
>seq->some_function_of(the second column of @ets[$i}
>}
>
>maybe that would be quicker???

Aaron Craig
Programming
iSoftitler.com

Reply via email to