1\t300\t1_a\t30\t1_b\t20 1\t300\t2_a\t22\t2_b\t12 1\t320\t1_a\t10\t1_b\t30 1\t320\t2_a\t32\t2_b\t22 2\t312\t1_a\t30\t1_b\t20 2\t312\t2_a\t22\t2_b\t12 2\t310\t1_a\t31\t1_b\t20 2\t310\t2_a\t21\t2_b\t12 #### 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