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
    Those are great articles and now I understand why not to do what I was trying to do. Of course it makes me feel stupid and humble, but I just don't see any other way to learn, do you? :-)

    Me thinks I'll just use a hash...

      Nobody knows everything. The only way to find out is to ask questions ;-)

      Don't feel too stupid, I had the same question, and the answer helped me too. :-)