Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does pack("B*", $s) do In Perl?

I am migrating some perl code to python and cant seem to understand what

pack("B*", $s)

does in perl.

Is there an equivalent in Python?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

pack:

B A bit string (descending bit order inside each byte)

It takes a bit string, and produces the corresponding bytes.

For example, pack "B*", "0100000101000010" is equivalent to "\x41\x42" and chr(65).chr(66).

$ perl -Mv5.10 -e'say sprintf "%vX", pack "B*", "0100000101000010"'
41.42
```
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading