hv_store#

Install an alias from $hash{$key} to an existing scalar, instead of copying its value in the usual way.

Synopsis#

my $sv = 0; hv_store(%hash, $key, $sv) or die “store failed”; $hash{$key} = 1; print $sv; # prints 1 — $sv and $hash{$key} share one scalar

After the call, $sv and $hash{$key} refer to the same SV: a later assignment through either name is visible through the other. Returns a true value on success, a false value if the store was rejected (for example, on a magical hash that refused the entry).

This is a low-level primitive with narrow uses; ordinary code should assign through the hash normally. Aliasing is fragile once the hash is duplicated, serialised, or passed through Storable.