in reply to Re: hash_reference from file
in thread hash_reference from file

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; }

Replies are listed 'Best First'.
Re^3: hash_reference from file
by choroba (Cardinal) on Sep 29, 2011 at 13:22 UTC
    You are absolutely right. I was typing too fast :)