gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:
I have a situation where I need to process some config files. The files are normally used in a ksh program for sourcing vars to the current env. In my program there is no need for them to be brought into the %ENV, I just need the key/value pairs. This part is easy.
What I would like to do is have a hash, say %basehash, that contains the same keys as in the config file. BTW, the keys will always be the same in the config files. In %basehash I would like to have the values set to a regex that describes what the value should look like in the actual config file. I would then like to load the config file into a hash, say $confighash, splitting on the '=' and making the LHS the key and the RHS the value.
Now, I would like to say something like 'if (%confighash == %basehash)'. I know it's not that simplistic, but it gets my idea across. What I don't what to do if I can avoid it is loop over one comparing it to the like key/value in the other.
??????
TIA, Chad.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing hashes
by rnahi (Curate) on Jun 06, 2003 at 17:58 UTC | |
|
Re: Comparing hashes
by DamnDirtyApe (Curate) on Jun 06, 2003 at 16:06 UTC | |
|
Re: Comparing hashes
by gnu@perl (Pilgrim) on Jun 06, 2003 at 16:12 UTC |