sub getChecksum($) {
my $in = shift;
my $check = 0;
$in =~ m/(?:(.)(?{$check += ord($1);}))*^/;
return $check;
}
####
$in =~ m/(?:(.)(?{print "ASCII value of '$1' is: ".ord($1)."\n"; $check += ord($1);}))*^/;
####
getChecksum called with: 'foo'
ASCII value of 'f' is: 102
ASCII value of 'o' is: 111
ASCII value of 'o' is: 111
will return '324'
getChecksum called with: 'foo'
ASCII value of 'f' is: 102
ASCII value of 'o' is: 111
ASCII value of 'o' is: 111
will return '0'
####
my @chars = split( //, $in );
foreach my $char (@chars) {
$check += ord($char);
}