I'd use:
$HoA{$key} = \@fields;
unless I really wanted to copy the elements in @fields. Most often I'd do that sort of thing in a loop where @fields is local to the loop and the assignment is performed at the end of the loop block.
The trap with either of variants you show is that only a shallow copy is made. If @fields contains nested elements then the references are copied, not the nested data. Using \@fields makes it just a little clearer (at least to me) in that case that danger lurks under the surface because it is clearer that there isn't much copying going on.
In reply to Re: Hash of arrays generation
by GrandFather
in thread Hash of arrays generation
by nemesisgus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |