in reply to Re: hash from sub directly into foreach loop
in thread hash from sub directly into foreach loop
Note that:
my $s = ();
is equivelent to
my $s = (undef);
which is equivelent to:
my $s;
The first use of a hash ref autovivifies the referred hash making the previous assignment redundant (and misleading). Consider:
use strict; use warnings; use Data::Dump::Streamer; my $s = (); Dump ($s); $s->{'a'} = 10 ; Dump ($s);
which prints:
$VAR1 = undef; $HASH1 = { a => 10 };
and note that the contents of $s changes from an undefined value to a hash ref.
If you really want to indicate intent with an assignment use:
my $s = {};
|
|---|