#!/usr/bin/perl use strict; use warnings; # 829503 # info to be extracted: chr1:67208779-67210057:+ my %loc; =head original with captures highlighted while(){ chomp; if(/^>(\w+)\s\w+\=(chr\w+)\:(\d+)\-(\d+)/) -------------$1------------$2------$3-----$4- $loc{$1} = "$2:$3:$4:$5"; print $loc{$1}."\n"; } } =cut while() { chomp; if(/^(.+)\s.+=(chr\d):(\d+)\-(\d+).+(?:=\+\s)(.*)/) { print "\t$1 | $2 | $3 | $4 | $5 |\n\n"; $loc{$1} = "$1:$2:$3:$4:$5"; print $loc{$1}."\n"; } else { print "No matches\n"; } } __DATA__ hg19_ensGene_ENST00000237247 range=chr1:67208779-67210057 5'pad=0 3'pad=0 strand=+ repeatMasking=none