#!/usr/bin/perl use strict; use warnings; my $line ; while () { next unless /\A (\w+[.]\w+) \s+ (.+) \z/xms; print unless $line->{ $1 }++; }; __DATA__ # Log file 13/3/2008 MA01001A1A03.f1 760 5640111 ad1 MA01001A1A03.f1 760 42572233 ubq MA01001A1A04.f1 300 15232924 ubq MA01001A1A04.f1 300 145334669 DNA # MA01001A1B22.f1 580 77745475 ra MA01001A1B22.f1 580 30409730 ra MA01001A1A03.f1 760 5640111 foo MA01001A1A04.f1 300 15232924 bar # End of log #### Output: MA01001A1A03.f1 760 5640111 ad1 MA01001A1A04.f1 300 15232924 ubq MA01001A1B22.f1 580 77745475 ra