use strict; use warnings; my $n = <>; chomp $n; my @array = split //, $n; my $total = 0; for(my $i = 0; $i < $#array + 1; $i++) { if($array[$i] =~ /\d/) { $total += $array[$i]; } } print "$total\n"; exit;