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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -