Benjamin Walkenhorst wrote: >Hello everybody, > >I've written a perl-module that stores some settings in a DBM-hash. >Currently, the module checks if certain keys have defined values in the >hash and if so, it copies the values belonging to those keys to the >corresponding variables. >These variables are filled with default values before, so they work even >if no such value is given in the hash. > >What I would like to do now: Iterate over the keys in the DBM-hash and >look if a local variable of the same name exists; if so, copy the value >from the hash to the corresponding local variable. > My initial idea is this (assuming you're talking about identity between local variable name and hash key name):
for (sort keys %dbm_hash) if (defined $$_) { $$_ = $dbm_hash{$_}; } Since there is no hard reference in $_, the dereferencing should be treated as a symbolic reference. - Jan -- There are 10 kinds of people: those who understand binary, and those who don't -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>