In order to enable utf8 pragma in one-liner, perl interpreter should be called with -Mutf8 option:
perl -Mutf8 -E 'my $人 = "human"; say $人'
The -C command line flag lets you control Unicode features. It can be followed by a list of option letters.
I - STDIN will be in UTF-8O - STDOUT will be in UTF-8E - STDERR will be in UTF-8S - shorthand for IOE, standard I/O streams will be in UTF-8echo "Ματαιότης ματαιοτήτων" | perl -CS -Mutf8 -nE 'say "ok" if /Ματαιότης/'
A - treats @ARGV as an array of UTF-8 encoded stringsperl -CA -Mutf8 -E 'my $arg = shift; say "anteater" if $arg eq "муравьед"' муравьед
i - UTF-8 is the default PerlIO layer for input streamso - UTF-8 is the default PerlIO layer for output streamsD - shorthand for ioperl -CD -Mutf8 -e 'open my $fh, ">", "utf8.txt" or die $!; print $fh "개미 조심해"'
-M and -C switches may be combined:
perl -CASD -Mutf8 -E 'say "Ματαιότης ματαιοτήτων\n"';