in reply to Reading Install type config file into hash
It depends a lot on how your code will process the resultant hash, but I'd consider adding a 'default' feature to those products that do not have features, just to make the code/hash structure consistent.
You can always exclude it (the default feature) from displays, when it is the only feature.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Reading Install type config file into hash
by tmurnane (Novice) on Aug 08, 2012 at 15:34 UTC | |
The following code works fine.
Is there a way of displaying it in the order it came in without using Tie::IxHash module. That is not on my system and will have to put in a ticket to have the module installed. My fear is that users of this script may not have it installed as well and thus would have to got through the same issue. Running the above code on this file:
produces this result:
As you can see - the results are unordered. | [reply] [Watch: Dir/Any] [d/l] [select] |
by BrowserUk (Patriarch) on Aug 08, 2012 at 17:19 UTC | |
Is there a way of displaying it in the order it came in without using Tie::IxHash module. That is not on my system and will have to put in a ticket to have the module installed. Do you have to have a ticket to install your code on your machine? Copy & paste the code into your own source file; and tell the controlling powers that you've done so. As you can see - the results are unordered. That is the nature of hashes. The use-cases for hashes don't require (or benefit) from them being ordered. Humans like things ordered, but programs don't give a damn. And if all you want to do is present the same information back to the users in the same form, just print the file to their screen. But if you really must remember the order, just make a note of it as you go:
Produces:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [Watch: Dir/Any] [d/l] [select] |
by tmurnane (Novice) on Aug 10, 2012 at 13:31 UTC | |
Thank you so much - that is exactly what I am looking for. I do need it ordered because I'm creating a Perl Tk UI that will read this setup file, allow users to modify it and write it back out...basically, creating a Suite installer outside of InstallShield. I'm thinking of using a NoteBook where the first tab will have a list of Products and Features with CheckBoxes. The other tabs will have the "Property = Value" info in a label Textbox fashion so they can change the values and write out a new setup.ini. I will also have another script that can be run from the UI and cmdline for users without UI capabilities, that will just read the setup.ini, build the commands to run each install silently and run them...where obviously, order does not matter. Still have to figure that one out - when running outside the UI, how do I determine what to install. I May have to add a Product="y|n", Feature="y|n" to the setup.ini file. Thanks a bunch - I knew to use Arrays of Hashes but couldn't conceptualize it visually. Boy do I have a lot to learn - who'd thunk to use an || in a Hash Key. Great stuff. If anyone has a better solution...by all means, let me know. | [reply] [Watch: Dir/Any] |