Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (9)
    As of 2014-07-29 07:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (211 votes), past polls