--- Stephen Henderson <[EMAIL PROTECTED]> 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.
maybe
> open (ACCS, "C:\\Perl\\BioPerl-0.7\\Seqdata\\Accession.txt") or die
> "can't open Accessions file";
while (<ACCS> { # chomp; # ???
(@x,@ets) = split;
}
> $ets_count=@ets;
> 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???
Probably. Try:
foreach (@ets) {
seq->some_function_of(/\t(.*)/)
}
First, foreach is almost *always* better that for(;;) in Perl.
Second, the function call puts it's args into a scalar context, so...
Third, the match operator will return the matched part of the string.
we used the default of $_ in the foreach and the match, so the arg
passed to seq->some_function_of() is the part of the current element of
@ets that is matched, i.e., everything after the \t (TAB).
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/