in reply to How to assign an array to a value in hash?
Your problem occurs in the mixed use of array and scalar values. The assignment $new_hash{$some_key1} = @some_array1 actually references @some_array1 in the scalar context (because $new_hash{$some_key1} is of the scalar data type). In the scalar context @some_array1 will simply return the number of elements in the array. If you want to save the actual array, assign a reference to the array into the hash such as $new_hash{$some_key1} = \@some_array1. This will preserve the array. You can now reference the elements of the array as $new_hash{$some_key1}[0], $new_hash{$some_key1}[1] etc
PJ
|