http://www.perlmonks.org?node_id=37395


in reply to What's the difference between chr() and pack('C',hex($1))?

There is a subtle difference that may bite you. chr works on characters while pack "C" works on bytes. With a standard ASCII character set, these are indistinguishable under most circumstances, but if you're using unicode (see perlunicode) data in later versions of Perl, chr and ord behave differently than their pack/unpack counterparts. pack/unpack will still work with individual bytes while chr/ord will actually deal with the full unicode character, which may be longer than 1 byte.
  • Comment on Re: What's the difference between chr() and pack('C', hex($1))?