From: Wolfgang Laun Date: Wed, 28 Nov 2001 20:35:29 +0000 (+0100) Subject: DRAFT perlpacktut.pod - minor diffs to v0.1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f8b4d74fa5fd7bb98a4694c41f28371fcf64a67a;p=p5sagit%2Fp5-mst-13.2.git DRAFT perlpacktut.pod - minor diffs to v0.1 Message-ID: <200111282035290250.0067732D@smtp.chello.at> p4raw-id: //depot/perl@13358 --- diff --git a/pod/perlpacktut.pod b/pod/perlpacktut.pod index 921fdc5..b102543 100644 --- a/pod/perlpacktut.pod +++ b/pod/perlpacktut.pod @@ -370,10 +370,10 @@ C and Perl. (If you'd like to use values from C<%Config> in your program you have to import it with C.) signed unsigned byte length in C byte length in Perl - C C sizeof(short) $Config{shortsize} - C C sizeof(int) $Config{intsize} - C C sizeof(long) $Config{longsize} - C C sizeof(longlong) $Config{longlongsize} + s! S! sizeof(short) $Config{shortsize} + i! I! sizeof(int) $Config{intsize} + l! L! sizeof(long) $Config{longsize} + q! Q! sizeof(longlong) $Config{longlongsize} The C and C codes aren't different from C and C; they are tolerated for completeness' sake. @@ -666,7 +666,7 @@ is added after being converted with the template code after the slash. This saves us the trouble of inserting the C call, but it is in C where we really score: The value of the length byte marks the end of the string to be taken from the buffer. Since this combination -doesn't make sense execpt when the second pack code isn't C, C +doesn't make sense except when the second pack code isn't C, C or C, Perl won't let you. The pack code preceding C may be anything that's fit to represent a @@ -996,10 +996,14 @@ and C: # Prepare argument for the nanosleep system call my $timespec = pack( 'L!L!', $secs, $nanosecs ); - # A simple memory dump +For a simple memory dump we unpack some bytes into just as +many pairs of hex digits, and use C to handle the traditional +spacing - 16 bytes to a line: + my $i; - map { ++$i % 16 ? "$_ " : "$_\n" } - unpack( 'H2' x length( $mem ), $mem ); + print map { ++$i % 16 ? "$_ " : "$_\n" } + unpack( 'H2' x length( $mem ), $mem ), + length( $mem ) % 16 ? "\n" : ''; =head1 Authors