in reply to creating the hierarchy pattern from the input file

So whatt you want to do is:

  • Loop over the input ,
  • split each line on '@',
  • built a tree of nested hashes with arrays as leaves
  • like push @{ hash{instreg}{d1} }, 'd1'

    ???

    UPDATED: So what's your code so far and where are you stuck?

    - Ron
    • Comment on Re: creating the hierarchy pattern from the input file
  • Replies are listed 'Best First'.
    Re^2: creating the hierarchy pattern from the input file
    by LanX (Saint) on Sep 16, 2021 at 09:23 UTC
      > built a tree of nested hashes with arrays as leaves

      That's not possible, because the input has varying depth causing conflicts.

      One parent level can't be hash and array at the same time.

      And hashes can't have duplicate keys. So maybe he rather wants nested arrays?

      If the OP didn't show code, then he should at least have shown valid target data.

      Update

      Or maybe the OP doesn't want data but just text displaying a tree?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

    Re^2: creating the hierarchy pattern from the input file
    by pruthvik (Initiate) on Sep 16, 2021 at 08:24 UTC

      Hi Ron,

      Yes but the array length keeps changing , so how do we consider that ?

      The expectation is the last element should be the value and all other elements should be the keys to each other , and also is there should be no repetition of the keys it should dbe uniq

      Thanks

        "and also is there should be no repetition of the keys it should dbe uniq"

        What?

        - Ron