in reply to Interpolation in variable names
Nothing to add to Corions answer, you don't want to use that. But if you still insist or are asking just out of curiosity, this works:
> perl -e '$size_orange=55; my $fruit = "orange"; my $name_var = "size +_$fruit";print $$name_var; print $size,"\n";' 55
Note that $size_orange has to be a global variable, it won't work when there is a 'my' before $size_orange. Instead of $$name_var ${$name_var} would also have worked, note the curly braces instead of your parentheses
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interpolation in variable names
by JavaFan (Canon) on Mar 16, 2010 at 11:11 UTC |