Easiest way to see what it does is to do it with lots of print statements.
use strict;
use warnings;
my $val = 0;
p('Zero');
$val |= 1;
p('Or-ed 1');
$val <<= 1;
p('shift 1');
$val |= 0;
p('Or-ed 0');
$val <<= 1;
p('shift 1');
$val |= 1;
p('Or-ed 1');
$val <<= 1;
p('shift 1');
$val |= 0;
p('Or-ed 0');
#Prints in binary with lowest bit to the right side.
sub p
{
printf '%20s : %4d => ', shift, $val;
print reverse split '', unpack'b*', pack'c', $val;
print "\n";
}
C:\>perl test.pl
Zero : 0 => 00000000
Or-ed 1 : 1 => 00000001
shift 1 : 2 => 00000010
Or-ed 0 : 2 => 00000010
shift 1 : 4 => 00000100
Or-ed 1 : 5 => 00000101
shift 1 : 10 => 00001010
Or-ed 0 : 10 => 00001010