in reply to Re: dynamically creating the name of a hash key-name
in thread dynamically creating the name of a hash key-name

To do this, you would need a piece of code like this:

#!/usr/bin/perl my ($i, @hasharray, $x); # create an array of hashnames (hash0..hash9) for ($i=0; $i<10; $i++) { push @hasharray, "hash$i"; } $i = 10; foreach (@hasharray) { $x = $_; #assign key "key" and value "value$i" to %hashx $$x{key} = "value$i"; $i++; } print "$hash7{key}\n"; #would print "value17"
But don't use strict or -w here! Strict would prevent using a string as a hashref ($$x{key} = "value$i") and -w would warn us that %hash7 was used only once...

So you see, it is possible, but I think it's not wise...

HTH

Jouke Visser, Perl 'Adept'