#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11148698 use warnings; use List::AllUtils qw( uniq_by ); open my $fh, '<', \<; # skip first line print uniq_by { (split)[1] } <$fh>;