GH> my %hash = %{ functionReturningReference() };
TZ> It's worth noting here that if the returned value is undef, the program
TZ> will die here. This is why I always use an intermediate variable and
TZ> test if for definedness, even if it takes a few more lines.
where did you get that result?
perl -e '%h = %{$x}'
perl -e '%h = %{undef}'
neither caused a die.
-w and "use strict" show different things. Note that the first test
shows that %{undef} doesn't mean what you and I thought it meant.
$ perl -we '%h = %{undef}'
Ambiguous use of %{undef} resolved to %undef at -e line 1.
Name "main::h" used only once: possible typo at -e line 1.
Name "main::undef" used only once: possible typo at -e line 1.
$ perl -we 'my %h = %{undef()}'
Use of uninitialized value at -e line 1.
$ perl -e 'my %h = %{undef()}'
[no output]
$ perl -we 'use strict; my %h = %{undef()}'
Can't use an undefined value as a HASH reference at -e line 1.