Decode everything that comes from the outside. Encode everything that leaves your program. use utf8;
Why use utf8;? As I understand the documentation, its purpose is to enable the source code to be in UTF-8 (so you can do e.g. my $ñ = 'foo'; where 'ñ' is not a single byte). It even says "Do not use this pragma for anything else than telling Perl that your script is written in UTF-8".
I thought the preferred way to decode/encode the program's input/output was by using Encode.
(Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling errors. Thank you!).