my @foo = qw(1 4 g 7 h rf s 4 6 7 9); my %foo = (); $foo{$_}=$foo[$_] for @foo; @foo=keys %foo;