my @array = qw( foo bar baz ); for (@array) { eval "$_ = 'value'"; # Error here!!! } #### #name your hash my %hash; #autovivify elements with names from the array.. #using undef simply means they will all be undef. # (all but the first one would be anyway, this just keeps things consistant). @hash{@array} = undef; # then to use your named array elements # eg. keyboard or web page. Assume we get the string 'foo' my $varName = getVarNameFromSomeWhere(); # then to use it $hash{$name} = 'we just gave $hash{foo} this as its value'; #and to print it print $hash{$varName}, "\n";