|more useful options|
bitwise string operatorby Anonymous Monk
|on Jun 13, 2013 at 16:42 UTC||Need Help??|
Anonymous Monk has asked for the
wisdom of the Perl Monks concerning the following question:
I found this post on-line and I am not clear exactly what is going on.
“…you will get a string of bytes with values zero and one, rather then the characters '0' and '1'. To make this printable just 'or' in a string of zeroes of the right length.”
$dd |= '0' x length $dd
I know what the result of this statement is but I am not sure exactly what (how) it is doing (it). I am comparing 2 strings (^) and when I do
$cmp |= '0' x length($cmp); # See rest of code below.
numbers magically appear and I can then see (print) what is in $cmp. So, what exactly does ‘or’ in a string of zeroes mean? Zeroes appear but so do other digits (“A” ^ “C” → 2). What does |= do? (or |= ‘0’) Is there some substitution occurring?My code: