in reply to printing referenced arrays weirdness

What do you expect the result will be for this?
print "test_array: @$test_array " . #{${@{$test_array}}} . "\n"; print "test_array2: @$test_array2\n";
Can you spot the error? Your code is equivalent to this (because of the comment # on the first line) -
print("test_array: @$test_array " . print "test_array2: @$test_array2 +\n");
Where your second print is evaluated before the first print.

If you want to print the index of the last element in the test array, use this ---> $#{@$test_array} instead