open(FILE, "sorted.file"); while () { if($_ != $previous) { print $current; $count++; } $previous = $_; } print "There are $count unique records";