in reply to Pack number to unsigned short
and many error/warning messages
You didn't feel it worthwhile to post (or, apparently, to ponder) | to ponder any of these error/warning messages, but it's sometimes useful to let Perl help you.
The Argument "gE" isn't numeric in printf at ... warningc:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; my $count = 17767; my $c16 = pack('S', $count); printf(qq{Count = dec %d, hex 0x%04x, c16 = 0x%04x \n}, $count, $count, $c16); " Argument "gE" isn't numeric in printf at -e line 1. Count = dec 17767, hex 0x4567, c16 = 0x0000
It's also possible to gain insight into the structure of a packed string (once you realize it is a string) with a quick, roll-your-own hex dumper:
(I'm sure there are better string hex dumpers avaliable on CPAN.)c:\@Work\Perl\monks>perl -le "use warnings; use strict; ;; my $count = 17767; printf qq{%d decimal, %x hex \n}, $count, $count; ;; for my $template (qw(S n v N V)) { printf qq{template '$template': }, $template; my $p = pack $template, $count; printf '%02x ', $_ for unpack 'C*', $p; print ''; } " 17767 decimal, 4567 hex template 'S': 67 45 template 'n': 45 67 template 'v': 67 45 template 'N': 00 00 45 67 template 'V': 67 45 00 00
Update: I notice now that you did, in fact, post many of the warning messages, so I've altered my reply accordingly.
Give a man a fish: <%-{-{-{-<
|
|---|