Re: To Reference or not to reference
- From: chas.owens@xxxxxxxxx (Chas Owens)
- Date: Thu, 29 Mar 2007 08:57:56 -0400
On 3/29/07, Dukelow, Don <don.dukelow@xxxxxx> wrote:
I've written a Perl program that declares a hash at the top of the
program "%myHask;". It has worked great until now when one sub program
seams to be making its own copy of the hash. I can find no typo's or
anything but there my still be one there. My question is would it be
better to pass the global hash by reference to each sub program to cut
down on possible typo errors or just leave it global and fix the problem
I have?
Don Dukelow
I can say with near 100% certainty that passing a ref is better than
using a global. Also, if you are finding your self writing code that
is focused around a hash that you are calling a number of functions on
then what you are really doing is writing OO code in a non-OO fashion.
Consider refactoring the code as object based instead of hash based.
.
- Follow-Ups:
- Re: To Reference or not to reference
- From: Marilyn Sander
- Re: To Reference or not to reference
- References:
- To Reference or not to reference
- From: Don Dukelow
- To Reference or not to reference
- Prev by Date: To Reference or not to reference
- Next by Date: Re: To Reference or not to reference
- Previous by thread: To Reference or not to reference
- Next by thread: Re: To Reference or not to reference
- Index(es):
Relevant Pages
|