Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Run length encode a bit vector

by ikegami (Patriarch)
on Jan 05, 2012 at 19:28 UTC ( [id://946462]=note: print w/replies, xml ) Need Help??


in reply to Re: Run length encode a bit vector
in thread Run length encode a bit vector

The parent could use B* instead of B32.

Methods that rely on unpack('B*', $bytes) can even handle arbitrary long packed string if they are packed in "network" (big endian) order.

my $bytes = pack 'N*', 0x01020304, 0x05060708; my $bits = unpack 'B*', $bytes; ...

(By the way, the == 1 is superfluous in the parent's code.)

Replies are listed 'Best First'.
Re^3: Run length encode a bit vector
by TJPride (Pilgrim) on Jan 05, 2012 at 20:42 UTC
    Odd, I would have thought that 0 as a string would still trigger true, and that in this context the pattern match would return 0 as a string. But I tested just now and you're correct, it works the same way without the ==.

      Zero is false, no matter if it's stored in an IV, UV, NV or PV.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://946462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found