in reply to Counting keys in a referenced hash

I think that your second assignment is not doing what you expect:
$test = ( test1 => '1', test2 => '2', test3 => '3');
This assigns the last value in the list to $test. Later, when you dereference it, treating it like a reference to a hash, you end up with an empty hash. Probably you meant to do this instead:
$test = { test1 => '1', test2 => '2', test3 => '3'};
The curly braces give you a reference to a hash. This should give you the expected result.
-JonathanU