#use strict; open ALUS, "Z:\\3\' UTR intron project\\Alu_bed.bed" ||die "couldn't open alus!!"; my %seen; while (){ /(chr.*?)\t/; if (exists $seen{$1}){ print $1 "$_"; }else{ $seen{$1}="whatever"; open $1, ">Z:\\3\' UTR intron project\\Alu_chroms\\$1.txt"||die "couldn't open $1 file!"; print $1 "$_"; } }