in reply to subroutine / dot operator / hash vlaue

in first case, when exactly perl runs subroutine? does it runs get_vlaue2() every time we try to access $hash->{key}?
You can use a few print statements to find this out:
print "Start\n"; my $hash = { key => 'value1' . get_value() }; print "hash created\n"; print "accessing hash key\n"; my $key = $hash->{'key'}; print "hash key is '$key'\n"; print "Finish\n"; sub get_value { print "get_value() called\n"; return "value"; }

Replies are listed 'Best First'.
Re^2: subroutine / dot operator / hash vlaue
by Anonymous Monk on Dec 10, 2015 at 03:21 UTC
    return gmtime.' '.rand ;