XP is just a number | |
PerlMonks |
Re: Handling binaryby Eily (Monsignor) |
on Sep 12, 2015 at 14:29 UTC ( [id://1141777]=note: print w/replies, xml ) | Need Help?? |
pack and unpack are, as a matter of fact a way to achieve what you want although it's not done in one step: The first transformation is pack "H*", $str where the hexadecimal numbers are turned into binary data. Then unpack "B*", $str; turns the binary data into a string consisting of the characters '0' and '1'. unpack "(A5)*", $str; is one of the many ways to split a string every five characters. Then, packing and unpacking those 5 bits strings into numbers would have been possible, but eval "0b$str" just does that in one step.
In Section
Seekers of Perl Wisdom
|
|