$old_col_0 = ''; $old_col_1 = ''; while () { #containing the above information chomp; my @temp_array = split(/\t/,$_); for (1 .. 2) { #arbitary number based on outside factor my $out_line = ''; if ($temp_array[0] ne $old_col_0) { $out_line = $temp_array[0]; # Space after data $out_line .= " "; $old_col_0 = $temp_array[0]; } else { # 1 space where data would have been, plus 1 more for # column spacing $out_line = " "; } if ($temp_array[1] ne $old_col_1) { # Make sure all subsequent uses of out_line are # append, not assignment $out_line .= $temp_array[1]; $out_line .= " "; $old_col_1 = $temp_array[1]; } else { # Four spaces, 3 for data, 1 for column spacing $out_line .= " "; } # A handy join to get the rest of the data # We don't want the 0th or 1st elements, they're # handled specially. $out_line .= join(" ", @temp_array[2..5]); print $out_line;