in reply to Re^2: Optimizing a Text Canvas: An inner loop and a cloner
in thread Optimizing a Text Canvas: An inner loop and a cloner

Right, I think I've got a bit figured out on the bitfields. However, this doesn't work as expected:

use constant AS_BG => 0; use constant AS_FG => 8; use constant AS_U => 16; use constant AS_BLINK => 17; use constant AS_BOLD => 18; my $test = 0; #$test |= ($v << $k); # set $k to $v #$test &= ~($v << $k); # print "Test0:[$test]\n"; $test |= 41 << AS_BG; $test |= 31 << AS_FG; $test |= 0 << AS_U; $test |= 0 << AS_BLINK; $test |= 1 << AS_BOLD; print "Test1:[$test]\n"; print "Test parts: ".($test >> AS_BG).", ".($test>>AS_FG).",".($test>> +AS_U).",".($test>>AS_BLINK).",".($test>>AS_BOLD)."\n";
Output:
Test0:[0] Test1:[270121] Test parts: 270121, 1055,4,2,1

Now, I'm sure I'm missing something here - but what? :-)