Ronald J Kimball wrote:

> On Tue, Jan 15, 2002 at 03:25:54PM -0600, Tomasi, Chuck wrote:
> 
>>@UserCache;   # Place to store data already seen
>>sub GetUser
>>{
>>      my ($id, $user)=@_;     # record number and hash reference to populate
>>
>         ^^^^^^^^^^^^^^^
> 
>>      if (defined($UserCache[$id])) {
>>
>>        $user = $UserCache[$id];                                            
>>        return(1);  
>>
> 
> $user is lexically scoped to the body of the subroutine; this assignment
> right before a return is pointless.
> 
> I guess you also have a global variable named $user, which is what you
> meant to set.  Global variables should generally be avoided; have GetUser()
> return the value instead.
> 
> BTW, I don't see where the hashes come in.  @UserCache is an array.
> 
> Ronald
> 
> 

Tomasi,

Are you wanting to be able to call getuser() like:
    $rtn = getuser($is, \%hash_to_populate);
ie. You want your return values in to be passed back through 
the hash reference you supply?

If so you probobly want to say something like:
    %$user = %{$UserCache[$id]};
in getuser().
Roger


-- 
There are lies, there are damned lies, and there are the 
power point presentations you make up to explain your code.

Reply via email to