ajcd@lfcs.ed.ac.uk (Angus Duggan) (03/21/90)
I've come across a problem which occurs when mixing bitwise operators with associative array components; if the numeric value of an associative array component is negative, it is converted to zero when the expression is evaluated. The same thing does *not* happen for other arithmetic operators. This also affects the bitwise assignment operators |=, &=, and ^= (I think; last two untested). Try the script: #!/usr/local/bin/perl $fonts{"cmr10",300} = 1; # Correct values printed by following statement print STDOUT "Values are ", $fonts{"cmr10",300}, ",", $fonts{"cmr10",300} - 0, ",", $fonts{"cmr10",300} & 1, ",", $fonts{"cmr10",300} | 0, "\n"; $fonts{"cmr10",300} = -1; # Incorrect values printed by following statement print STDOUT "Values are ", $fonts{"cmr10",300}, ",", $fonts{"cmr10",300} - 0, ",", $fonts{"cmr10",300} & 1, ",", $fonts{"cmr10",300} | 0, "\n"; The output of this script is: Values are 1,1,1,1 Values are -1,-1,0,0 The second line should read: Values are -1,-1,1,-1 perl -v prints: $Header: perly.c,v 3.0.1.4 90/02/28 18:06:41 lwall Locked $ Patch level: 15 This is being run on a Sun 3/50 with SunOS 4.0.? In the instance in which it occurred, I can use || instead of |, but I'd prefer not to. Anyone other workarounds welcome. Angus == Angus Duggan, Department of Computer Science, | #include <stddisclaimer.h> University of Edinburgh, JCMB, | USENET: ajcd@lfcs.ed.ac.uk The King's Buildings, Mayfield Road, | JANET: ajcd@uk.ac.ed.lfcs