Benjamin Walkenhorst wrote: > > Hello everybody, Hello,
> 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. > > Is such a thing possible? And if so, how should I do it? Could I create > a command dynamically and run it via eval? Instead of using "local variables" store your defaults in a hash, for example: my %defaults = ( a => 1, b => 2, c => 3, d => 4, ); use GDBM_File; tie %hash, 'GDBM_File', $filename, &GDBM_WRCREAT, 0640; @defaults{ keys %hash } = values %hash; untie %hash; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>