while (<DATA>) { my @line = split; my %hash; @hash{+KEYS} = @line; push @array, {%hash}; }
Why create a hash in the lexical scope of the while loop and then make a copy of that hash instead of just using a reference to that lexically scoped hash?
while (<DATA>) { my %hash; @hash{ +KEYS } = split; push @array, \%hash; }
In reply to Re^2: hash_reference from file
by jwkrahn
in thread hash_reference from file
by hmadhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |