#!/usr/bin/perl -w use strict; my @inputs = qw(first second third fourth fifth first); my %found; my @values; for my $element (@inputs) { if (!$found{$element}) { push @values, $element; ++$found{$element}; } } print "@values\n"; #### first second third fourth fifth