in reply to Re: p0fq.pl and pack?
in thread p0fq.pl and pack?

Thank you for the reply!

I changed the pack and unpack to your suggestion, but I got "Bad response magic." error.

perldoc -f pack:

v An unsigned short in "VAX" (little-endian) order.
V An unsigned long in "VAX" (little-endian) order. (These ’shorts’ and ’longs’ are _exactly_ 16 bits and _exactly_ 32 bits, respectively.)

I don't understand what "$score -= 65536 if $score > 32767;" means, I don't have that in the original script, should I add it in?

Replies are listed 'Best First'.
Re^3: p0fq.pl and pack?
by ikegami (Patriarch) on Feb 20, 2007 at 02:19 UTC

    but I got "Bad response magic." error.

    What are the bytes of $response?

    I don't understand what "$score -= 65536 if $score > 32767;" means

    There is no code for "A signed short in 'VAX' (little-endian) order.", so I extracted an unsigned short, and that converts it to a signed short.

      I add
      print join(" ", map { sprintf "%#02x", $_ } unpack("C*",$response)), " +\n";
      it print out bytes like

      0xd 0xef 0xac 0xed 0x78 0x56 0x34 0x12 0x1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

        ... = unpack ("N V ...", $response);

        I don't see how "L L ..." would have worked on the PC (or any machine).

      Please pardon my ignorant :)
      How can I print out the bytes of $response?
      print $response gives me garbled strings