#!/usr/bin/env perl #Uses: perl sub-seq.pl input.txt range use strict; use warnings; my $end = pop; my $start = pop; local $/ = '>'; while (<>) { chomp; next unless /(.+)/; my ($header) = "$/$1_$start-$end\n"; my $seq = ${^POSTMATCH}; $seq =~ s/\s//g; print $header; print +( substr $seq, $start - 1, $end ) . "\n"; }