in reply to Bug in perl bitwise or??

This is a result of Perl's loose typecasting. If perl thinks your operands should be treated as strings, it will operate accordingly. How did you set the initial values of those variables, and what do you do with them just before the |= happens?

Its not a bug, more of a subtle result of loose typecasting. If you set the variables in string context, i.e.
$prevFlagBin = "3221225472";
It is treated as a string.

Replies are listed 'Best First'.
Re: Re: Bug in perl bitwise or??
by Anonymous Monk on May 21, 2003 at 21:56 UTC
    You are possibly correct. I had populated the value with unpack and an A10 value in that position. However, I thought it was in numeric context since the debug statement just before it had no single quotes around it.

    By the way its v5.6.1 on HPUX.

    Thanks

      (Perhaps unfortunately) The "x" command in the Perl debugger determines whether to put quotes around a value based on whether the value matches /^\d+(\.\d*)?\Z/ (see dumpvar.pl), not based at all on whether or not Perl considers the value to be a string, a number (of one of several types), or both. For example:

      DB<1> x -1 0 '-1' DB<2> x 1e19 0 '1e+019' DB<3> x "123" 0 123
      "Go figure."

                      - tye
      One way to test my theory would be to, immediately before the |= , add zero to each variable. That would force numeric context for the addition, and perl would still consider the vars as numbers for the |=.