Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Don't they want to get a list "e.g. ( 1, 0, 0, 1, 1, 0 ... )" as stated in the beginning of that section,

Why not just try it out?

$vec = pack 'V', int( 2**32* rand() );; print $bits;; 011000001111110110010000101101 @ints = (); { use integer; push @ints, 0 if $bits =~ s/^(\d)// && $1; push @ints, pos $bits while $bits =~ /1/g; };; print @ints;; 1 2 8 9 10 11 12 13 15 16 19 24 26 27 29

The are producing a list of the positions of the bits that are set.

I do agree that the section title and description and the sub name are woefully bad.

I'm also less than impressed with the claims for efficiency:

C:\test>perl -MMath::Random::MT=rand -minteger -MBenchmark=cmpthese $vec = pack 'V*', map int( 2**32* rand() ), 1 ..10;; cmpthese -1, { a=>q[ my @ints; my $bits = unpack 'b*', $vec; use integer; push @ints +, 0 if $bits =~ s/^(\d)// && $1;push @ints, pos $bits while($bits =~ +/1/g); ], b=>q[ my @ints = grep{ vec( $vec, $_, 1 ) } 0 .. length( $vec ) -1; ] +, };; ^Z Rate a b a 22306/s -- -79% b 108646/s 387% --

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Confusion about code sample in perlfaq4 by BrowserUk
in thread Confusion about code sample in perlfaq4 by vr

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: Jeez .... UTF8 in my company is driving me crazy

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (4)
    As of 2018-03-19 23:17 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (246 votes). Check out past polls.