John Ross wrote:

> Thank you to all of you who responded to my question about pasing hashes
> into a function.   The -> operator did the trick.
> My problem was that I thought once I passed the hash in, I could
> dereference it   That doesn't appear to work like I expected.
> 
> sub mod_hash {
>     my $hash_ref = @_;
>     my %hash = %$hash_ref;
> 
>  
>     $hash{key} = 0;
> 
> 
> etc,etc,etc.
> 
> It appears that that just makes a local copy of the hash, then disposes of
> that copy at the end of the subroutine.  I think I kind of understand why
> this doesn't work.
> 
> Thanks again for you help,
> 
> John
> 

change:

my $hash_ref = @_;

to:

my ($hash_ref) = @_;

but once you deference it and assign it to another hash like:

my %hash = %$hash_ref;

it's no longer acting on the hash ref. in other word, when you do:

$hash{key} = 0;

it will NOT affect $hash_ref anymore.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to