The problem with vec is that it will only deal with powers-of-two numbers of bits. For example, there is no way to get at your 7-bit field directly using vec.
Aiee! I had found the existence of vec and had it in a tab on my browser but had not studied it at the time I wrote that update...

I had also done a CPAN search ( for "bits", as I recall) and there was one bit-manipulating utils module there (I don't recall the exact name) that had the same restriction (only operable on fields of 1,2,4,8... bits). Since these data structures tend to be dreamed up by hardware/comms engineers who are concerned with cramming the maximum amount of "useful" information into the smallest amount of bits, that restriction is not very helpful.

Getting a 7-bit field back as 7 individual 0|1s isn't ideal.
But it may be the least ugly/painful way. There's obviously MTOW to do it but not all are equally attractive.

The last signature was better than this one

In reply to Re^2: Factoring out common code in two methods of a class by jvector
in thread Factoring out common code in two methods of a class by jvector

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.