Although 65536 is a number familiar to anyone in our binary centered world, here it may well be an arbitrary choice. It still seems uncomfortably "C-like" to me. I'll bet this entire logic can be replaced by calls to existing, known-good CPAN code... therefore, do so. When in Perl, do as the monks do, etc...