perl code:
my %config = (
randValue => int(rand(10)),
);
print $config{ randValue }."\n";
print $config{ randValue }."\n";
will produce:
8
8
Is it possible to get different value each time? (execute int(rand(10))
each time the $config{ randValue }
is called)
You can either use tied hash, or function:
my %config = (
randValue => sub { int(rand(10)) },
);
print $config{randValue}->();
print $config{randValue}->();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With