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.