Cicatrix has asked for the wisdom of the Perl Monks concerning the following question:

i have put a file contents in a hash. file is of nested blocks which contain critical data. i need to introduce a value inside particular nested block, say E. well the file contents is as below - a { b { c { E { XXXXXX=YYYYY } } } } How efficiently can i traverse through the hash/file and get my job done without affecting other blocks/data ?
  • Comment on File: set a new value inside a nested block

Replies are listed 'Best First'.
Re: File: set a new value inside a nested block
by Anonymous Monk on Jan 20, 2011 at 05:16 UTC
    How efficiently can i traverse through the hash/file and get my job done without affecting other blocks/data ?

    Is this a trick question? You can use Benchmark to measure the efficiency of your code.

Re: File: set a new value inside a nested block
by tospo (Hermit) on Jan 20, 2011 at 09:24 UTC
    Do you mean "what is a good way of doing this?" or "what is the fastest/most memory-efficient way of doing it?". If it's just how to do it then I would say the above example looks easy enough to crack with a regular expression or did you run into problems with that?
      The replies to String Search provide code for dealing with very similar data.
      tospo, Need the best and efficient way to do this. being an amateur its hard to get thru this :( thanks