$sum = 0;
$sum += $_ for unpack 'C*', "This is a string to change to binary";
print $sum;;
3325
Or print unpack '%32C*', "This is a string to change to binary";;
3325
But the result will be modulo 2**32 (assuming it ever gets that high; which won;t happen until your strings are at least 16 million characters long.
If that was a concern, on a perl with 64-bit ints you can do: print unpack '%64C*', "This is a string to change to binary";;
3325
Which will handle strings to at least 72057594037927936 bytes, which should be enough to be going on with :)
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|