in reply to Byte repetition check

Just don't use smartmatch... And if files are small, I don't see any reason to read them byte by byte.
$ perl -0777 -nE ' my $count = 0; $count += length $2 while /(.)(\1+)/g; say $count; ' <<< "1112223333" 7 $ perldoc perlop | perl -0777 -nE ' my $count = 0; $count += length $2 while /(.)(\1+)/g; say $count; ' 22788
(just don't decode your strings, and you'll have bytes... pretty much)