/(.{1,4})/
should be
/(.{1,4})/s
grep $_, split /(.{1,4})/s, $buffer
is buggy. Fix:
$buffer =~ /(.{1,4})/sg
So much simpler too!
hex sprintf "%02X"x4, map { ord } split //, $_
can be simplified to
unpack 'N', "$_\0\0\0"
The latter should be much faster too.
In reply to Re^6: CRC of a string
by ikegami
in thread CRC of a string
by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |