tmurnane has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to read a config file that will have something like the following information:
Product1 property=value property2=value Product2 feature1 property=value property2=value feature2 property3=value Product3 feature1 property=value property2=value
I need to read this file in and display it in a Perl Tk project. I'm just having a hard time figuring out how to keep track of the features because not all products have features.
@file = <IN>; foreach(@file){ if (/^TSS/){ # All product begin with TSS # Its a product }elseif ($_ =~ /=/){ # get the property and value using split }else{ # Its a feature??? } } # Should I use something like: $hash{$product}{$feature}{$property} = "value"; # or $hash{$product}{$property} = "value"; $hash{$product}{feature} = "feature name"; # if the feature key is her +e, there is a feature. # but how do I keep properties listed after the correct feature!
Obviously some sort of Hash should do the trick but having hard time visualizing it. Any help is appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading Install type config file into hash
by BrowserUk (Patriarch) on Aug 06, 2012 at 21:05 UTC | |
by tmurnane (Novice) on Aug 08, 2012 at 15:34 UTC | |
by BrowserUk (Patriarch) on Aug 08, 2012 at 17:19 UTC | |
by tmurnane (Novice) on Aug 10, 2012 at 13:31 UTC |