willyyam has asked for the wisdom of the Perl Monks concerning the following question:
What I am trying to do may be stupid/daft/wrong-headed; any alternate methods would be appreciated.
I wanted to put a variable name together dynamically inside a sub, based on the arguments of that sub. For instance, if the first argument is "example" and the second is "other", I wanted to define a variable called $exampleother1, or $exampleother2. I can concatenate variables and strings, but I don't know how to concatenate a string and then make it a variable name.
Because this seems hard/strange I suspect that it is also idiotic, but I think I'm better off asking for the wisdom (and tolerance) of the monks then to sit in ignorance.
Update: Yep, stupid, daft and wrong-headed. Using a data structure to capture my cases makes more sense then trying to build case-specific variables. I should stop asking questions and just re-read the Llama book each time I find something difficult. Thanks for the suggestions, guidance and references.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dynamically Building Variable Names
by Roy Johnson (Monsignor) on Apr 22, 2005 at 17:50 UTC | |
Re: Dynamically Building Variable Names
by Fletch (Bishop) on Apr 22, 2005 at 17:03 UTC | |
by jhourcle (Prior) on Apr 22, 2005 at 17:37 UTC | |
Re: Dynamically Building Variable Names
by polettix (Vicar) on Apr 22, 2005 at 17:17 UTC | |
by dragonchild (Archbishop) on Apr 22, 2005 at 17:33 UTC | |
Re: Dynamically Building Variable Names
by samizdat (Vicar) on Apr 22, 2005 at 17:12 UTC | |
by merlyn (Sage) on Apr 22, 2005 at 17:16 UTC |