hill has asked for the wisdom of the Perl Monks concerning the following question:
When this:
$data{$tab} = \@array;
is executed in a loop where $tab and @array change, every resulting $data{$tab} contains the value of the @array associated with the final $tab.
$data{$tab} = \@array;
is executed in a loop where $tab and @array change, every resulting $data{$tab} contains the value of the @array associated with the final $tab.
Changing the initial line to invoke an anonymous reference:
$data{$tab} = [@array]
works a treat.
Any explanations would be most welcome.
|
---|
Back to
Seekers of Perl Wisdom