sxmwb has asked for the wisdom of the Perl Monks concerning the following question:
Here is a code sample
The results are:#!/usr/bin/perl -w use strict; my ($testp, $n, $s); $testp = 0x007102; $n = length($testp); $s = 2*$n; print ("Hex 0x",unpack("H$s", $testp), "\n"); $testp = "\x30\x05\x15"; $n = length($testp); $s = 2*$n; print ("Hex 0x",unpack("H$s", $testp), "\n");
Expected results:Hex 0x3238393330 Hex 0x300515
I am trying to understand why the differences in the processes above.Hex 0x007102 Hex 0x300515
Another question about dealing with Hex values in perl, what is best way to do addition and multiplication, basic math? Convert to decimal and then to the math?
Thanks Mike
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Differences in behavior in pack
by apl (Monsignor) on Apr 08, 2008 at 20:38 UTC | |
|
Re: Differences in behavior in pack
by runrig (Abbot) on Apr 08, 2008 at 20:40 UTC | |
by sxmwb (Pilgrim) on Apr 09, 2008 at 00:48 UTC | |
by ikegami (Patriarch) on Apr 09, 2008 at 01:15 UTC |