http://www.perlmonks.org?node_id=1038618


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?