JonathanPrice has asked for the wisdom of the Perl Monks concerning the following question:
hello I am having a bit of an issue (i am new to perl) i have written a script that is supposed to read a FASTA file hopefully this will scroll through the file search for ">" and header (it does this). then save this line and the next line in two separate scalars. but it stops after reading the next line? does anyone know why this is? or how i can make it so that it carries on reading the file after finding the 1st correct sequence?? this is my code. thank you.
use strict; use warnings; my($filename) = "fasta.txt"; open(FILE, $filename); while(<FILE>) { my($line) =$_; if($line=~/^>/ and $line =~ /unknown/ ) { my($header) =$line; print $header; <FILE>; print $_; } } close FILE; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: While loop stops after reading new line?
by toolic (Bishop) on Oct 03, 2013 at 19:28 UTC | |
|
Re: While loop stops after reading new line?
by CountZero (Bishop) on Oct 03, 2013 at 19:51 UTC | |
|
Re: While loop stops after reading new line?
by Marshall (Canon) on Oct 04, 2013 at 12:15 UTC |