use strict; use warnings; my %loc; while () { chomp; if (/^>(\w+)\s\w+\=(chr\w+)\:(\d+)\-(\d+).*\+(.*)/) { $loc{$1} = "$2:$3:$4:$5"; print $loc{$1} . "\n"; } } __DATA__ >hg19_ensGene_ENST00000237247 range=chr1:67208779-67210057 5'pad=0 3'pad=0 strand=+ repeatMasking=none #### chr1:67208779:67210057: repeatMasking=none #### if (/^>(\w+)\s\w+=(chr\w+):(\d+)-(\d+).*\+(.*)/) {