Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by frozenwithjoy (Priest)
on Jun 12, 2013 at 23:33 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1038618]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found