in reply to Weird behaviour with match-time code evaluation and backtracking

Under Perl 5.10 you will get the warning that $check cannot be closed over:

Q:\> perl -wle "sub c{my$c=0;$_[0]=~m/(?:(.)(?{$c += ord($1);}))*^/;$c +}c('foo')" Variable "$c" will not stay shared at (re_eval 1) line 1.

I'm not sure what the generic workaround is though, but I avoid code in regular expressions - I guess in a general case, I would use a split+reduce approach instead. In your specific case, the checksum can also be calculated using unpack:

sub getChecksum { unpack '%A*', $_[0] };