Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am after "00204110" but I'm not sure if the sprintf version is portable
#!/usr/bin/perl -- use Data::Dump; my $raw ="\1\24\2\0" ; dd( 'a is this portable? ', sprintf '%08X', unpack q/L</, $raw); dd( 'b is this portable? ', sprintf '%08X', unpack q/V/, $raw ); dd( 'g is this portable? ', unpack 'H*', pack 'L>', unpack q/L</, $raw + ); __END__ ("a is this portable? ", "00021401") ("b is this portable? ", "00021401") ("g is this portable? ", "00021401")
Also, a way to shorten up the pack/unpack?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sprintf %X endianness
by BrowserUk (Patriarch) on May 14, 2013 at 14:41 UTC | |
by Anonymous Monk on May 14, 2013 at 19:58 UTC | |
by SuicideJunkie (Vicar) on May 14, 2013 at 21:06 UTC | |
by Anonymous Monk on May 14, 2013 at 21:15 UTC | |
by BrowserUk (Patriarch) on May 14, 2013 at 21:50 UTC | |
by Anonymous Monk on May 14, 2013 at 22:46 UTC | |
by BrowserUk (Patriarch) on May 14, 2013 at 23:23 UTC | |
| |
|
Re: sprintf %X endianness
by andal (Hermit) on May 15, 2013 at 07:11 UTC | |
|
Re: sprintf %X endianness
by ikegami (Patriarch) on May 15, 2013 at 20:08 UTC |