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