in reply to Re^2: zero fill with pack
in thread zero fill with pack

what is the significance of the ", 0," in the "pack('NN', 0, $_)" statement?

The value for the first "N".

Q=654848 ----------------------- 00 00 00 00 00 09 fe 00 ----------- ----------- N=0 N=654848

I also need to pad the above value with two spaces, i.e., "00 00 00 00 00 09 fe 00 20 20"

More concisely, you want to add two spaces. pack:

C An unsigned char (octet) value. A A text (ASCII) string, will be space padded.
pack('NN CC', 0, $_, ord(' '), ord(' ')) pack('NN CC', 0, $_, 0x20, 0x20) pack('NN A2', 0, $_, ' ') pack('NN n', 0, $_, 0x2020)

Replies are listed 'Best First'.
Re^4: zero fill with pack
by Spooky (Beadle) on Jun 23, 2010 at 16:54 UTC
    AWESOME ikegami - Thanks!!
Re^4: zero fill with pack
by Spooky (Beadle) on Jun 25, 2010 at 13:21 UTC
    ikegami - I found out I need to be able to handle one or two bytes worth of data adding nine or eight spaces: e.g., 00 20 20 20 20 20 20 20 20 20 or 00 00 20 20 20 20 20 20 20 20 Is there something smaller than an unsigned short (16bit)? I'm trying to figure out the correct pack template to use for the above examples.
      ikegami - I think I figured it out for myself using the "i" and "n" templates....