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


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

Personally, the decision as to whether to return a hash or a hash reference would be made on the basis of the size of the hash, and the frequency with which the subroutine is called. If the hash is small and the subroutine is only called a few times, I might return the whole thing simply because it makes the notation for using the hash much simpler in the calling code.

Of course, that can be overcome by passing a reference to a hash declared in the calling code to the sub and having it populate it. The return then becomes (almost)irrelevant, serving only as a marker that the hash may have been modified. Though you might opt to return undef if the sub was unable to complete its task, and the passed hashref if successful.

It's worth pointing out that your example sub could be replaced by my %INPUT = $CGI->Vars; or $INPUT = $CGI-Vars;.

See section "FETCHING THE PARAMETER LIST AS A HASH:" in the CGI.pm pod for more info.


Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.