Loading ...
Sorry, an error occurred while loading the content.

Recursive Hashes!!

Expand Messages
  • sumanth_sharmakr
    Say I have some data like one/a/aa/eee one/b/gg/kkk one/a/ff/ttt/rrrr ##Length or fields may be of any length Consider $line3 = one/a/ff/ttt/rrrr ; I ll split
    Message 1 of 1 , Dec 29, 2003
    • 0 Attachment
      Say I have some data like

      one/a/aa/eee
      one/b/gg/kkk
      one/a/ff/ttt/rrrr


      ##Length or fields may be of any length
      Consider $line3 = "one/a/ff/ttt/rrrr";

      I'll split it as

      @levels = split /\\/, $line3;
      ##@levels contains ( one a ff ttt rrrr )

      Suppose i want to automate the process of converting this array into
      recursive as

      $level{ one }{ a }{ ff }{ ttt }{ rrrr } = 1;

      Assuming that at level one the value is constant,
      How do I achieve this(Hash) when the number of such levels for each
      line keeps changing.

      So that I can compress the three lines and print them as

      one
      a
      aa
      eee
      ff
      ttt
      rrrr
      b
      gg
      kkk
    Your message has been successfully submitted and would be delivered to recipients shortly.