my %hash = ( all => 'old' ); # simple hash value foo(\%hash); # pass reference to hash sub foo { # recieve reference aliased as $_[0] my $ref = shift; # copy reference to $ref (and throw away the $_[0] alias) $ref = { all => 'new' }; # overwrite the copy of $ref # this creates a *new* hash and a new reference in $ref # %hash is not modified } #### my %hash = ( all => 'old' ); # simple hash value foo(\%hash); # pass reference to hash sub foo { # recieve reference as $_[0] my $ref = shift; # copy reference to $ref (and throw away $_[0]) $ref->{ all } = 'new'; # overwrite the value to the key 'all' # in the hash pointed to by $ref (which is %hash) }