- or download this
sub getChecksum($) {
my $in = shift;
...
$in =~ m/(?:(.)(?{$check += ord($1);}))*^/;
return $check;
}
- or download this
$in =~ m/(?:(.)(?{print "ASCII value of '$1' is: ".ord($1)."\n"; $chec
+k += ord($1);}))*^/;
- or download this
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'
- or download this
my @chars = split( //, $in );
foreach my $char (@chars) {
$check += ord($char);
}