[Bioperl-l] how to break a while loop

chen li chen_li3 at yahoo.com
Sun Jan 8 11:26:59 EST 2006

Hi all,

I have a big file containing mutiple records. I just
need to read a few of them. I use the following code
(copy from Bio::SeqIO HOWTOs with small changes)but it
seems to me that it will never end untill the whole
file is read. My question: how do I break the loop?



use warnings;
use strict;
use Bio::SeqIO;

# get command-line arguments, or die with a usage
 my  $usage = "perl SeqIO_8.pl  infile infileformat
outfile outfileformat\n";
          my $infile = shift or die $usage;
          my $infileformat = shift or die $usage;
          my $outfile = shift or die $usage;
          my $outfileformat = shift or die $usage;
          my $filesize= -s $infile;
          print "\nThe file size is $filesize.\n";

 # create one SeqIO object to read in,and another to
write out
   my $seq_in = Bio::SeqIO->new('-file' => "<$infile",
                               '-format' =>
   my $seq_out = Bio::SeqIO->new('-file' =>
                                 '-format' =>

          # write each entry in the input file to the
output file
         my $count=0;
         while (my $inseq = $seq_in->next_seq){

              print "\nThis is the record
              if ($count=10){exit;}# break a while



Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 

More information about the Bioperl-l mailing list