while () { #containing the above information chomp; my @temp_array = split(/\t/,$_); for (1 .. 2) { #arbitary number based on outside factor my $pop_tracker = $_; if ($temp_array[0] == $pop_tracker) { print $temp_array[0]; #I want this to only print once. #more print statements here to reflect the below output. } } # I want: 1 - 300 1_a 30 1_b 20 2_a 22 2_b 12 320 1_a 10 1_b 30 2_a 32 2_b 22 # 2 - you get the idea... #Not: 1 - 300 1_a 30 1_b 20 1 - 300 2_a 22 2_b 12 1 - you get the idea... 1 - some info 2 - some info 2 - some info 2 - some info 2 - some info