in reply to Construction/initialisation of empty hash

It's creating a key/value pair with the reference address to an empty hashref as the key and undef as the value. This behavior is deprecated, as you would have noticed had you enabled warnings. (Either with the -w flag or with use warnings; somewhere above that initialization line.)

You'll probably want to add use strict; at the top and work through the warnings errors. Trust me.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Replies are listed 'Best First'.
Re: Re: Construction/initialisation of empty hash
by muntfish (Chaplain) on Apr 27, 2004 at 14:41 UTC

    Thanks for the quick reply!

    In the original module, I do have use strict; at the top. Did you mean to say "You'll probably want to add use warnings; at the top..." in your second paragraph?

    Just using the -w flag for now, this does show warnings under both 5.004 and 5.8.0, however it would still be interesting to know how/why the behaviour has changed.

      I meant "errors", not "warning". Original node updated.

      Usually, one has the my as part of the variable initialization, like my %foo = ();, not separately. Perl is closer to C++ and Java than C, in that regard. Also, you can just say my %foo; and it will work as expected.

      As for why it changed ... I have no idea. 5.004_xx is somewhat different than 5.005_xx and above, in any number of ways. I wouldn't look to compare the two. (The way to think about them is that 5.004 is really 5.4, as compared to 5.6 and 5.8.)

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose