http://qs321.pair.com?node_id=216281


in reply to Subroutines: Returning a hash vs. hash reference

If you are creating CGI scripts (which I think you are) and are using Template to create the HTML then hash refs are a better idea. For example if you have a function such as $hash_ref = get_user_details($user_id) you can do this:

# %output is the hash that will be passed to Template. $output{user_details} = get_user_details( $user_id );

This allows you to send data straight through to Template without having it hang around in your script. You could certainly do the same with a function that returns a normal hash with a step in between, but it is easier to standardise on hash refs and then to know that you can always do the above.