bcarroll has asked for the wisdom of the Perl Monks concerning the following question:
Here is an example from the file:
HKEY_LOCAL_MACHINE\SOFTWARE\Vendor\Product\CurrentVersion\Tokens\Encotone\SerialNumberUserAttribute=12345
LanMan:= ; REG_SZ
LDAP:= ; REG_SZ
ODBC:= ; REG_SZ
I am trying to figure out how to take the HKEY_LOCAL_MACHINE line and build a hash of hashes. If I were building the hash manualy, I would normally do it like this:
The problem is that I am parsing a textfile and trying to build the hash of hashes dynamically, because I don't know which registry-like keys will be included.$hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}=12345; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'LanMan'} +{'Value'}=""; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'LanMan'} +{'Type'}="REG_SZ"; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'LDAP'}{' +Value'}=""; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'LDAP'}{' +Type'}="REG_SZ"; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'ODBC'}{' +Value'}=""; $hash{'HKEY_LOCAL_MACHINE'}{'SOFTWARE'}{'Vendor'}{'Product'}{'CurrentV +ersion'}{'Tokens'}{'Encotone'}{'SerialNumberUserAttribute'}{'ODBC'}{' +Type'}="REG_SZ";
Of course I will need another variable to store where in the hash the current key is to add the "Key name", "Value" , and "Type" for the lines that follow the HKEY... line, but I am not too concerned about that right now.
Anybody have any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: split string into hash of hashes...
by BrowserUk (Patriarch) on Mar 03, 2013 at 01:45 UTC | |
|
Re: split string into hash of hashes...
by davido (Cardinal) on Mar 03, 2013 at 01:54 UTC | |
|
Re: split string into hash of hashes...
by LanX (Saint) on Mar 03, 2013 at 02:05 UTC | |
by bcarroll (Pilgrim) on Mar 03, 2013 at 04:23 UTC | |
by LanX (Saint) on Mar 03, 2013 at 13:23 UTC | |
|
Re: split string into hash of hashes...
by punch_card_don (Curate) on Mar 03, 2013 at 16:52 UTC |