Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: subroutine / dot operator / hash vlaue

by tangent (Parson)
on Dec 10, 2015 at 02:44 UTC ( [id://1149861]=note: print w/replies, xml ) Need Help??


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 ;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1149861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-16 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found