Unicode in your source
But you don't have to type code points or even their names everytime.
You can use any Unicode symbol in source code,
for example in your string literals.
All you have to do,
is to use utf8
pragma and then to save your script as UTF-8 text file.
Watch this:
use utf8; binmode STDOUT, ":encoding(UTF-8)"; my %notes = ( quarter => '♩', eighth => '♪', ); while (my( $k, $v ) = each %notes) { say "$k note is $v"; }
Even more, you can use Unicode symbols in your indentifiers
use utf8; my $cliché = 42; say "The answer is $cliché!";
and inside regular expressions!
use utf8; my $snowman = "Hello, I'm \x{2603}."; say 'Snowman is here!' if $snowman =~ /☃/;
Exercise
Edit this piece of code by filling internationalized country code top-level domains.
Hint: this list might help.
use utf8; binmode STDOUT, ":encoding(UTF-8)"; my %tlds = ( Russia => ..., Ukraine => ..., ); say "ccTLD for $_ is '$tlds{$_}'" for keys %tlds;