#!/usr/bin/env perl use strict; use warnings; use 5.010; my $hash = { key => ' value1 '.get_value2()}; say $hash->{key}; say $hash->{key}; say $hash->{key}; $hash = { key => ' value2 '.get_value2()}; say $hash->{key}; say $hash->{key}; say $hash->{key}; sub get_value2 { return rand(); }