#usr/local/bin/perl -w use strict; use Bio::SeqIO; #headers format #4 133005667 133005842 open(FILE,"/home/sakti/Desktop/trackseq_129S5_129S1/129S5ref_129S1qry_chr4_nonredundant") || die "cannot open file"; my $seqio = Bio::SeqIO->new(-file => "/home/sakti/Desktop/trackseq_129S5_129S1/135_155_129S5.fasta", -format => "fasta"); while(){ chomp($_); my @temp_data = split (/\s+/,$_); #Make name for the N files like 4_3000027_3020133.fsa my $name="4_".$temp_data[1]."_".$temp_data[2].".fasta"; open (CORE,">$name"); while(my $seq = $seqio->next_seq) { print CORE $seq->subseq($temp_data[1],$temp_data[2]), "\n"; } close(CORE); } close(FILE);