#!/bin/perl -w use strict; open TMP, "input.txt" || die ("could not open the input file \n"); my (%hash, @columns); for () { chomp; @columns = split ; next unless ($columns[1] && $columns[2]); if (not exists $hash{$columns[1].$columns[2]}) { $hash{$columns[1].$columns[2]}=1; print $_."\n" ; } } close TMP;