use strict; # will use this variable to hold third # column value of the last record. my $last_val; while() { chomp; next unless (m/.*.*\s*(\d{2,})/); # third column value has changed? print "\n" unless ($last_val == $1); # yes, skip to next line print; $last_val = $1; } __DATA__ 076194 (041352) 02311 94 (0.00) 027 94 (NG012) 089294 (04/23/2002) 0494 94 (520-004) 1343 38 (info) 1133 38 (info) 1345 94 (info)