lightoverhead has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I may have a silly question.

When I use pack template "c" which is 8-bit value integer, what will "pack" pack the data if the value I feed the pack is above 255?

How will "pack" arrange it in bits?

Thanks

Replies are listed 'Best First'.
Re: question about pack
by TomDLux (Vicar) on Oct 15, 2013 at 00:14 UTC

    Why don't you try it and tell us? Something like ...

    for my $data ( 250 .. 260 ) { my $packed = pack 'c', $data; printf "%X => %X\n", $data, $packed; }

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

      ... or perhaps better as:

      >perl -wMstrict -le "my $cp = pack 'c*', 256 .. 260, 320 .. 324; print qq{'$cp'}; "

      They are all "0"