in reply to Re^2: How can I modify received socket messages in Perl?
in thread How can I modify received socket messages in Perl?

You don't have a header and body, just a bunch of bytes. First things first, you need to identify the header and the body.
  • Comment on Re^3: How can I modify received socket messages in Perl?

Replies are listed 'Best First'.
Re^4: How can I modify received socket messages in Perl?
by bonny95 (Initiate) on Mar 10, 2009 at 04:43 UTC
    Yes,you're right. I know I have to identify the header and body, that's why I convert messages in $buffer(binary) into @msg.
    The question is after I insert 3 bytes into @msg, I don't know how to convert modified message in @msg into the type that can be sent out by syswrite().

      I doubt it's necessary or even helpful to create @msg.

      And populating it with the hex nibble pairs is particularly backwards. Populating it with the values of each bytes would make more sense if there's any reason to create @msg in the first place.

      my @msg = unpack('C*', $buffer); ...do something to @msg... $buffer = pack('C*', @msg);