in reply to Read an input file in two hashes to retain order

Hi Bioinfocoder,

It looks like your file is basically an ini-style file with sections, keys and values, with the addition of the "nice name" subsection labels.

I would remove the "subsection" labels, which are really part of your presentation, and put them in a hash keyed by the real config names for lookup and use when needed. Then I would use Config::Tiny::Ordered to read from and write to the file.

Edit: Since you say "The order of First_Name, Last_Name and Age within each location can change and even order of locations can change, but each location section should remain separate and intact" you could just use Config::Tiny which is a little easier to work with since you use named hash keys rather than array indices to work with the config settings.

Hope this helps!


The way forward always starts with a minimal test.
  • Comment on Re: Read an input file in two hashes to retain order

Replies are listed 'Best First'.
Re^2: Read an input file in two hashes to retain order
by Bioinfocoder (Novice) on Mar 18, 2016 at 16:19 UTC
    thanks 1nickt for the response, I was trying hashes as the input file might end up having many variables and different user input options at later stages, for eg just calling one location etc, so I thought to start with hashes. I will try the Config::Tiny as well. I remember using Template module earlier, but it was messing up with the location+it's variables orders.