Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: array of binaries to hex conversion

by remiah (Hermit)
on Sep 12, 2012 at 02:12 UTC ( #993120=note: print w/ replies, xml ) Need Help??


in reply to Re: array of binaries to hex conversion
in thread array of binaries to hex conversion

Hello.

I would like to ask you a question. The result will differ by byte orders.

my $tmp=pack("B32", substr("0" x 32 . join('',@rand1), -32)); #this prints 'as 32bit big endian:0x2abb1' printf "as 32bit big endian:0x%x\n", unpack('N',$tmp) ; #this prints 'as 32bit little endian:0x200' printf "as 32bit little endian:0x%x\n", unpack('S',$tmp) ;
There is "<" for little endian, and ">" for big endian, which pack,unpack offers. OP treats it as "N"=32bit int, big endian, so I would like to do like this.
pack("B>32", $bitstring);
pack("(B32)>*",$bitstring);
But both of them doesn't work...
How can I add endian specification with your one line conversion? Is there a good way?


Comment on Re^2: array of binaries to hex conversion
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-07-28 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (185 votes), past polls