http://qs321.pair.com?node_id=430731


in reply to Adding scalars but with a twist..

If they are package variables, you can use symbolic references:
my $sum = 0; foreach my $i (1 .. 80) { no strict 'refs'; $sum += ${"Sel${i}Ttl"}; }
If not, you can use 'eval':
my $sum = 0; foreach my $i (1 .. 80) { $sum += do {eval "$Sel${i}Ttl"} }
Or if you want to get fancy:
my $sum = 0; local $" = "+"; eval "\$sum = @{[map {qq {\$Sel${_}Ttl}} 1 .. 80]}";
All code untested.