in reply to error when passing hash as reference causes

You can also make your print_h_byref code a little easier to read by using the example from the documentation of the "each" function:
sub print_h_byref { my $href = shift; while (my ($key, $value) = each %$href) { print " Key: $key,\t Value: $value\n"; } }
Your print_h function makes a local copy of the hash. You should be aware that this may become an issue for large hashes, or if it is called a large number of times.