Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In a perfect world, your data would always know what their encodings were, and Perl could figure it out for you. Sadly, that’s not the real world. Someone hands you some bytes, Perl doesn’t know what encoding it should be, and it’s up to you to figure it out. Not only that, you might get data that specifies an encoding that is a lie.
The best advice is to ensure that you properly decode all of your input. That is, you have to take the octets and turn them into a proper character string. Don’t trust anything.