ddc_nh has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks, I am trying to build the name of a variable using the content of another variable. How can I access the content of this new variable? I hope the question is clear, but I am giving here a small example: <\p> <code> my $fruit = "orange"; my $name_var = "size_$fruit"; # name of the new variable my $size = $($name_var); # ??? does not work <\code>
Seems something very trivial to do, but I cannot find how to do it in the PERL manual... Thank you very much for your kind help. <\p>
Sorry, I am very confused how to use this tagging stuff :( <\p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interpolation in variable names
by Corion (Patriarch) on Mar 16, 2010 at 10:06 UTC | |
by ddc_nh (Initiate) on Mar 16, 2010 at 14:29 UTC | |
by Hue-Bond (Priest) on Mar 16, 2010 at 15:49 UTC | |
|
Re: Interpolation in variable names
by FunkyMonk (Bishop) on Mar 16, 2010 at 10:52 UTC | |
|
Re: Interpolation in variable names
by jethro (Monsignor) on Mar 16, 2010 at 10:16 UTC | |
by JavaFan (Canon) on Mar 16, 2010 at 11:11 UTC |