Perl preprocessor appended to other variable -
i trying write following code, want $varpre1 $var1 , $varpre2 $var2 after preprocessor evaluated, not working. there work around?
#define pre1 1 #define pre2 2 $var1 = 10; $var2 = 20; print $varpre1; print $varpre2;
what wrote doesn't make sense c preprocessor, since varpre1
parsed 1 token.
what want sort of possible, using called symbolic references, a bad idea.
$pre1 = '1'; $pre2 = '2'; $var1 = 10; $var2 = 20; print ${'var' . $pre1}; # same print $var1 => 10 print ${'var' . $pre2};
this not work under use strict refs
. bad idea not use strict refs
.
Comments
Post a Comment