I have separate configuration files that are separate, because they contain passwords and other sensitive data, and I do not mind seeing the world. So let's say I have:
sensitivedata = { password : 'foobaz', hostname : 'quux' };
globalconfig = { timeout : 86400, port : 5190 };
and I want to globalconfighave fields passwordand hostname. I can just do:
globalconfig.hostname = sensitivedata.hostname;
globalconfig.password = sensitivedata.password;
but it is tiring when there are many fields. As a perl programmer, I want to do something like this:
@{ $globalconfig }{ keys %{ $sensitivedata } } =
@{ $sensitivedata }{ keys %{ $sensitivedata } };
@{ $globalconfig }{ qw{ password hostname } } =
@{ $sensitivedata }{ qw{ password hostname } };
this can be done with help as well map, but that is exactly what we have hashrefslice syntax for perl. Is there a way with one application to match a bunch of fields from one dictionary to another?
This happens to me when I write this, that I could also do this in perl:
subname( { %$globalconfig, %$sensitivedata } );
... , , "" / javascript. ( , , , sensitivedata globalconfig).
; " ". node , , , .