#!/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(); } #### value1 0.557144237523065 value1 0.557144237523065 value1 0.557144237523065 value2 0.0543176085661514 value2 0.0543176085661514 value2 0.0543176085661514