Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Subroutines: Returning a hash vs. hash reference

by EvdB (Deacon)
on Nov 28, 2002 at 11:21 UTC ( #216281=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://216281]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2023-11-28 23:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found