#!/usr/bin/perl while (<>) { next if (defined $list{$_}); $list{lc($_)} = [ $i++, $_ ]; } print map { $_->[1] } sort { $a->[0] <=> $b->[0] } values %list;