|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
This message is one of several periodic postings to DevShed's Perl forum intended to make it easier for Perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with every Standard Distribution of Perl. --------------------------------------------- How do I manipulate arrays of bits? Use pack() and unpack(), or else vec() and the bitwise operations. For example, this sets $vec to have bit N set if $ints[N] was set: $vec = ''; foreach(@ints) { vec($vec,$_,1) = 1 } And here's how, given a vector in $vec, you can get those bits into your @ints array: sub bitvec_to_list { my $vec = shift; my @ints; # Find null-byte density then select best algorithm if ($vec =~ tr/ $J$Jvv \iv gv<Pvdv fvRv $ivovhv$rwvTbv pvtzv|q gvcv P$JP$J bvTjv\}v$wv<Qv|ovD\v LpvzvdyvD{vdmv]v lhv<%r yv[vqvZv @ dvXvv* ^« 0vv$qdvvdvbv field5 A vvvv* « pvvvvv$vv field6 A Xvvvv* *« vvvvvdvv%r field7 A vvwv* « vvv$wvvv field8 A vvXwv* « 0wvt vdwvvv field9 A wvwv. > |