I was trying to write a Perl program that would take in two strings representing binary numbers (i.e. consisting of only the characters "1" and "0") as input and print out the result of bitwise ORing the two numbers together (printing the result in binary as well).
In doing so, I created the following program which does exactly this, but I am struggling to understand exactly why it works:
my $a = "1000100101101";
my $b = "0100111000101";
print($a | $b); # prints "1100111101101"
I know that perl automatically convert strings into numbers when used in a number-like context, but it has always been the case that it converts such strings into base-10 numbers.
Why does this program seemingly perform a bitwise OR on two strings of binary digits?