Thanks RE: lexical problems (i think)

nkuipers nkuipers at uvic.ca
Mon Aug 26 17:18:43 CDT 2002


>sub parse_fasta_file {
>   my ($fh, $href) = @_;
>   my ($header, $sequence);
>   while (<$fh>) {
>     /^>(.*)/ and $header = $1;
>     next unless /^[acgtACGT]+$/;  # I guess there must be some junk lines
>     s/\s//g;
>     $href->{$header} .= $_;
>   }
>}

Looks like that works.

I have one other question, this is related to filehandles.

Take a look at this subroutine.  I am warning you right now that it's a 
low-brow way to get the job done, but that's the point.

sub segregate_by_def {
	no strict 'refs'; #ugh
	my $href = shift;
	my @fharray = ('Ava', 'Sma', 'Nhe',
                       'Fok', 'Hpa', 'Tc',
                       'LINE', 'SINE', 'MISC',);
	for my $fh (@fharray) { open $fh, ">>name.${fh}" or die $!; }
	for (keys %$href) {
	     if ( / ([SL] (?:ma|INE) |Ava|Nhe|Fok|Hpa|Tc) /x ) {
			my $handle = $1;
			print $handle   ">$_\n$href->{$_}\n";
	     } else { print MISC ">$_\n$href->{$_}\n"; }
	}
}

Is this *really* bad?

Thanks again,

Nathanael




More information about the Victoria-pm mailing list