Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: while loop on binary : \x30

by AnomalousMonk (Archbishop)
on May 16, 2016 at 20:49 UTC ( [id://1163171]=note: print w/replies, xml ) Need Help??


in reply to while loop on binary : \x30

Another approach:

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @strings = map pack('H*', $_), '30abff', 'ab30ff', '30', 'ab1a30'; dd \@strings; ;; for my $bs (@strings) { printf 'here: '; my @bits = unpack '(B8)*', $bs; print join '//', @bits; } " ["0\xAB\xFF", "\xAB0\xFF", 0, "\xAB\x1A0"] here: 00110000//10101011//11111111 here: 10101011//00110000//11111111 here: 00110000 here: 10101011//00011010//00110000
Please see pack, unpack, perlpacktut.

Update: Added another example string:  '30abff'


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1163171]
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: (5)
As of 2024-04-18 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found