in reply to subroutine / dot operator / hash vlaue

To answer your question more directly, in the first case, Perl runs the subroutine once, when the line of code you showed is run, then prepends 'value 1' to the result and stores that in the hash. You can easily prove this thusly:
#!/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(); }
Output:
value1 0.557144237523065 value1 0.557144237523065 value1 0.557144237523065 value2 0.0543176085661514 value2 0.0543176085661514 value2 0.0543176085661514
Every time my get_value2 is called, it will return a different random number, but you can see in the output that the value printed changed only when I re-set the hash, not each time the hash was accessed.

But I agree that this smells like an XY Problem. What are you actually trying to accomplish (or what bug are you actually attempting to identify) here?