in reply to Populating a nested hash with itself?

It seems to me that this code is building an arraya list, and then loading it into a hash. While building the arraylist, $hashref points to an empty hash.

I'm a little unsure what order things happen in behind the scenes, maybe hash assignment is done one entry at a time, so the first entry is created and added to the target variable so that the second entry can refer to it, but I doubt it.

  • Comment on Re: Populating a nested hash with itself?

Replies are listed 'Best First'.
Re^2: Populating a nested hash with itself?
by ikegami (Patriarch) on Jul 06, 2005 at 14:59 UTC
    I'm a little unsure what order things happen in behind the scenes, maybe hash assignment is done one entry at a time

    Parens have higher precedence than the assignment operator, so the list (nit: it's a "list", not an "array") is contructed before the assignment is performed. This isn't a hash constructor. There isn't such a thing in Perl. The code creates a list, which is then assigned to the hash.

      Yes, that's what my inner C programmer told me, but I don't trust Perl not to do some crazy magic (DWIMer?)