#!/usr/bin/perl my $previous; while (my $line = ) { if ($line =~ /^(.*)\t(.*)$/) { if ($previous eq $1) { print "$2"; } else { if (defined $previous) { print "\n" } print "$1\t$2"; } $previous = $1; } } print "\n";