Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: creating the hierarchy pattern from the input file

by The Perlman (Scribe)
on Sep 16, 2021 at 08:18 UTC ( [id://11136808]=note: print w/replies, xml ) Need Help??


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

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: note [id://11136808]
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others scrutinizing the Monastery: (1)
    As of 2024-04-25 02:28 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found