# Choose the Nth FASTA record # Called as "perl script_name.pl line_number file_name" use warnings; use strict; $/= '>'; my $line_number = shift; while(<>) chomp; if ($.-1 == $line_number ) { print; exit 0; } } #### # Choose any Range of FASTA records # Called as perl script_name.pl --start start_line --end end_line file_name # both --start and --end are optional; # no --start => start reading from end of file, end at --end # no --end => start reading from --start, read to end of file # neither => print every line use warnings; use strict; use Getopt::Long; my ($start, $end) = (undef, undef); GetOptions( "start=i" => \$start, "end=i" => \$end, ); $/='>'; while(<>) { if( (!defined($start) || $start <= $.) && (!defined($end) || $. <= $end) ) { print; }