Hi -

I really thought I understood pack/unpack,
but this has me stumped. I can't find anything to 
explain the operation of the following script
in the documentation:

use strict;
use warnings;

my $buffer = pack( "NN", 22, 0 );
printf "buffer length = %s\n", length $buffer;
print "buffer ",
    join( " ", map { sprintf "%02x", ord( $_ ) } split "", $buffer ),
    "\n";
my( $len1, $len2 ) = unpack "NN", $buffer;
printf "len1 = %s len2 = %s\n",
    $len1 || 'undef', $len2 || 'undef';

which gives this result:

$ perl tpack.pl
buffer length = 8
buffer 00 00 00 16 00 00 00 00
len1 = 22 len2 = undef

Why is len2 undefined instead of 0? Any ideas?
I am using perl 5.8.7 on Gentoo.

-- 
Aloha => Beau;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to