#!/usr/bin/perl use strict; use warnings; my %seen; open my $out, '>', 'output.txt' or die $!; while( my $line = ){ my ($id) = split /\s+/, $line; unless( $seen{$id}++ ){ print $out $line; } } close $out or die $!; __DATA__ 5.0 2.08 9.496 23 10.0 2.08 5.917 39 10.0 2.08 5.917 39 15.0 1.02 6.823 75 20.0 1.01 14.810 80 20.0 1.01 14.810 80 25.0 1.61 27.117 37 30.0 1.61 71.563 72 30.0 1.61 71.563 72