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

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().
  • Comment on Re^4: How can I modify received socket messages in Perl?

Replies are listed 'Best First'.
Re^5: How can I modify received socket messages in Perl?
by ikegami (Patriarch) on Mar 10, 2009 at 05:18 UTC

    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);