bebe has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, could you please get some help with the code below. It works but I think I'm doing this conversions very inefficiently, I was wondering if you have other suggestions or better alternatives I could use. I appreciate it all. :-)
# rand1 is array of binaries # basically, I want to convert array of binaries to hex string my $bin = arraystring (@rand1); my $dec = stringdecimal($bin); my $hex = sprintf("0x%x", $dec); sub stringdecimal { return unpack("N", pack("B32", substr("0" x 32 . shift, -32))); } sub arraystring { my $string = join('', @_); return $string; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array of binaries to hex conversion
by jwkrahn (Abbot) on Sep 11, 2012 at 05:49 UTC | |
by bebe (Novice) on Sep 11, 2012 at 06:57 UTC | |
by remiah (Hermit) on Sep 12, 2012 at 01:41 UTC | |
by Anonymous Monk on Sep 12, 2012 at 02:15 UTC | |
by remiah (Hermit) on Sep 12, 2012 at 11:44 UTC | |
|
Re: array of binaries to hex conversion
by Anonymous Monk on Sep 11, 2012 at 07:02 UTC | |
by remiah (Hermit) on Sep 12, 2012 at 02:12 UTC |