in reply to bit-wise boolean ops behave differently when observed

Try this:

my $bitfield = 1; my $modifier = '+2+16+1024'; my @fields = ( $modifier =~ m{ ([+-]) (\d+) }gxms ); # extract mods while ( @fields >= 2 ) { # for each modification my $op = shift @fields; my $value = shift @fields; if ( $op eq '+') { $bitfield |= $value; # set a bit w/ OR } } print "bf: $bitfield\n"; __END__ bf: 1043

That's the desired result, right? If I change the first line:

my $bitfield = '1';

...then I get 3624. This isn't the result you got (3562), but I still think the problem is that you're starting out with a string somewhere, or you're using strings where you think you have numbers. This way...

my $bitfield = '1'; $bitfield = 0+$bitfield;

...the result goes back to 1043.