Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Subroutines: Returning a hash vs. hash reference

by EvdB (Deacon)
on Nov 28, 2002 at 11:21 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-28 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found