Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by frozenwithjoy (Curate)
on Jun 12, 2013 at 23:33 UTC ( #1038618=note: print w/ replies, xml ) Need Help??


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

You're welcome. What exactly do you mean when you say "`do` a file"?


Comment on Re^3: Storing/parsing perl data structure in/from a file
Re^4: Storing/parsing perl data structure in/from a file
by Wilderness (Novice) on Jun 12, 2013 at 23:52 UTC
    I mean, when I do `do $file`, Perl would read the entire data structure at once and overwrite hash keys with the last value it reads. I wish there was a way for me to traverse through the data structure (which Perl would be doing internally to be able to find key collisions) manually.
      It's correct that do file means slurp + eval but your data only defines an anonymous hash on the top level.
      { alpha => { beta => { gamma => theta, delta => lambda, }, beta => { gamma => zeta, }, }, },

      you need to add a variable name!

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        How can I manually slurp + eval if I have a named hash?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2015-07-05 03:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls