Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^9: Storing/parsing perl data structure in/from a file

by LanX (Canon)
on Jun 13, 2013 at 22:45 UTC ( #1038851=note: print w/ replies, xml ) Need Help??


in reply to Re^8: Storing/parsing perl data structure in/from a file
in thread Storing/parsing perl data structure in/from a file

Sorry, but what exactly is your intention?

If it's just ease of syntax why don't you use YAML like I showed you?

If it has to be Perl syntax use multilevel arrays like I showed you, too.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re^9: Storing/parsing perl data structure in/from a file
Re^10: Storing/parsing perl data structure in/from a file
by Wilderness (Novice) on Jun 13, 2013 at 22:52 UTC
    Sorry to make it confusing but my intention is to be able to `do` a file with the information below and flag that key alpha->beta and later alpha->beta->gamma is defined twice. Duplicate keys can be at any level of the multi-level hash.
    { alpha => { beta => { gamma => theta, delta => lambda, }, beta => { gamma => zeta, }, }, },
      No this is your approach, you should explain your intention to use such a weird approach.

      I'm sure we can help you, if we just knew why ... this smell like an XY Problem! =)

      Your dump isn't even valid Perl code (barewords as values)!

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        Sorry to have completed pissed you off. It's ironical that I know it is an XY problem, yet I do not know what X and Y are...Anyways, after looking at all the responses, I wanted to know more about tying hashes and being able to override methods like STORE, FETCH, etc. to make them work for my multi-dimensional hash. But I haven't used OO-Perl before so I am struggling to write my own recursive methods to make it work for multi-level structures. I will go with YAML. It looks a lot more elegant than perl hashes in a file.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-09-20 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls