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? :-)


In reply to Re^3: Optimizing a Text Canvas: An inner loop and a cloner by JosiahBryan
in thread Optimizing a Text Canvas: An inner loop and a cloner by JosiahBryan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.