Good post++

One words of caution though. If you take another look at my post at Re: sorting a vec, you'll find that I have replaced the code

print unpack '(B4)*', $vec;

With

print map{ vec( $vec, $_, 4) } 0 .. 99;

The reason is that the first example doesn't do what I originally thought, and not what I still think would be the most intuative reading of the code.

Using the unpack format '(B4)*', doesn't return every set of 4 bits from the string. It returns every other 4-bits from the string! That is, the output consists of a list of numbers, the value of each being determined from most significant 4-bits of each byte of the input string, with the other 4-bits being summarily discarded. (*)

Only noticed this a while after posting (I noticed that the string I had carefully packed 100 4-bit fields into was only outputting 50 values when printed with the original code).

This was changed within about 1/2 an hour of the original post, at a time when then CB was quiet, and there were only 8 people listed in others users. You must have grabbed the code pretty quickly after I posted the original.

I apologise for my error. I don't believe that this affects the information in your post, but if it does, feel free to transfer all the blame to me.

*It also worth noting that '(b4)*', also grabs the same, most significant, 4-bits of each byte, with the others being discarded -- but it starts processing the bytes in the string from the other end. Very confusing and non-intuative.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!


In reply to Re: A good lesson on Tie ( My error!) by BrowserUk
in thread A good lesson on Tie (through a negative example) by pg

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.