in reply to Expression inside hash
If you want to evaluate each expression and then store the result in the hash, 1nickt’s answer is what you’re looking for. But if you want to store unevaluated expressions in the hash and evaluate them later, you need the “string eval” form of eval:
use strict; use warnings; my %g_tun = qw( R1 100*32+1 R2 1 R3 100*32+1 ); printf "G is %d\n", eval "$g_tun{R1}";
Output:
13:43 >perl 1584_SoPW.pl G is 3201 13:45 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Expression inside hash
by Anonymous Monk on Apr 04, 2016 at 03:52 UTC | |
by Anonymous Monk on Apr 10, 2016 at 18:14 UTC | |
by beech (Parson) on May 04, 2016 at 07:55 UTC |