in reply to How to refer to a scalar variable dynamically?

You could accomplish that by using "soft" references but it is not recommended to use them since they pollute your namespaces.
Instead, use a hash; e.g.,
my %vars = ( 'login' => undef, 'campaign' => undef, 'work' => undef, ); foreach my $func ('login','campaign','work') { my $tmp = calc_difference($var1, $var2); $vars{$func}{tot} = $tmp; # Or just append 'tot' to the key, e.g., # $vars{"${func}_tot"} = $tmp; }
--perlplexer