You're right about needing to use a reference to an array for assigning to a hash element, but that way of doing it can be rather wasteful. What you are doing with $Tex{$a} = [@bex] is copying the contents of @bex in to another array and then assign a reference to that new array to $Tex{$a}.
You can avoid the unneccesary copying by just taking a reference to the original array
if (!$Tex{$a}){ $Tex{$a} = \@bex; }
Of course, this only works correctly in a loop if the array you are taking a reference to is scoped to the loop. If not, your method is correct.
In reply to Re^2: Hash problem
by BrowserUk
in thread Hash problem
by Gnat53
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |