#!/usr/bin/perl ($root,$gene) = (@ARGV); open(TXT,$root.".txt") || die "Cannot open $root.txt"; open(FASTA, $root.".fasta") || die "Cannot open $root.fasta"; $found=0; while () { ($start,$stop) = m/^$gene \((\d+)..(\d+)\)/io || next; $found=1; last; } die "Did not find gene $gene in $root.txt" unless $found=1; $found = 0; while () { chop; @x=split; if ($x[0] >= $start) { # start-logic here; } } while () { chop; @x=split; if ($x[0] <= $stop) { # stop-logic here } } # print logic here #### rps12 -(92301..93101) rps7 -(91772..92242) ndhB -(89236..91472) trnL -(88584..88664) trnI -(84881..84954) rpl23 -(84433..84714) rpl2 -(82930..84414) #### http://www.ncbi.nlm.nih.gov/nuccore/11994090?report=fasta&log$=seqview