I thought that too when I first came across it. Here's the way I remember it now: Perl has its own internal way of storing the data - don't worry about what it is, just know that it's some special thing. When your code acquires data (from STDIN or another filehandle or a database or a web request) the data has some encoding. To process it you need to decode it from that encoding into the special internal format, so you use decode. Conversely when sending data out of perl (to STDOUT or a database or a web response or ...) you need to encode it back into what the receiving system expects so you use encode. This is why it helps to think of utf-8, utf-16, Latin-1, etc. as encodings (and this is indeed what they are).
All the magic shortcuts you might come across such as encoding layers are performing these operations automatically for you but really it's just decode and encode under the bonnet.
In reply to Re^3: Match full utf-8 characters
by hippo
in thread Match full utf-8 characters
by Allasso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |