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

Re: Unpacking variable length bit fields

by ikegami (Patriarch)
on Jun 18, 2012 at 21:27 UTC ( [id://976907]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @fields;
    my $bits = unpack('B*', $input);
    ...
       my $field = substr($bits, 0, $num_bits, '');
       push @fields, $field;
    }
    
  2. or download this
    use Config qw( );
    use constant UV_BITS => $Config::Config{uvsize} * 8;
    
    die if $num_bits > UV_BITS;
    push @fields, pack('B*', substr(("0" x UV_BITS).$field, -UV_BITS));
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-20 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found