my $number = 23; my @bits = split //, $number; my $total; for my $bit (@bits) { $total += $bit; } print "Number=$number Total=$total\n";