first_n_bases.pl 206 B

123456789101112131415161718
  1. #!/usr/bin/perl -w
  2. #
  3. use strict;
  4. my $n = shift or die("Usage: $0 <num_of_bases> [fasta_file]\n");
  5. my $m = 0;
  6. while(<>){
  7. if(/^>/){
  8. last if($m >= $n);
  9. } else {
  10. $m += length($_) - 1;
  11. }
  12. print;
  13. }
  14. 1;