#!/usr/bin/perl -w use strict; use Data::Dumper; my @array = ("white","blue","yellow"); my %hash = (); foreach my $temp (@array) { $hash{$temp} = $temp; } print Dumper \%hash; print join (" ",keys %hash); #### $VAR1 = { 'white' => 'white', 'blue' => 'blue', 'yellow' => 'yellow' }; white blue yellow