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, |
In reply to Re: Expression inside hash
by Athanasius
in thread Expression inside hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |