what's the best way to find the set bits in the output from select?

I really didn't want to do a brute force loop over every bit in the vec.
Would something like this be faster?

perl -le '$vec = pack "N", 0xF00F0001; $a = unpack ("b*", $vec); print $a; while ($a 
=~ /1/g) {print pos ($a)-1}'

00001111111100000000000010000000
4
5
6
7
8
9
10
11
24


is there an "official" cunning recipe for this?

Nicholas Clark

Reply via email to