in reply to How to refer to a scalar variable dynamically?
First off, you almost certainly want to use a hash instead of doing this. Have a read of Why it's stupid to `use a variable as a variable name', A More Direct Explanation of the Problem and What if I'm Really Careful?.
For example do this:
my %totals; foreach my $func ('login','campaign','work') { my $tmp = calc_difference($var1, $var2); $total{$func) += $tmp; }
If you really need to do it do a super search on symbolic references :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to refer to a scalar variable dynamically?
by noslenj123 (Scribe) on Apr 17, 2003 at 17:00 UTC | |
by adrianh (Chancellor) on Apr 17, 2003 at 21:01 UTC | |
by RolandGunslinger (Curate) on Dec 09, 2003 at 19:55 UTC |