perl - Why I can't use interpolated variable as varname? -
unfortunatelly, did not figure out, why $alfa
remains empty:
use 5.014; no strict 'refs'; $berta = 5; $gamma = 'berta'; $alfa = ${$gamma}; "'$alfa'";
must simple... expected $alfa
become 5
here. missed?
i think problem code works global variables, not lexical variables declared using my
. see faq.
our $berta = 5; $gamma = 'berta'; $$gamma; # 5
obviously, not idea in production code.
Comments
Post a Comment