How does given/when (smartmatch ~~, experimental) interact with Unicode and encodings?

In Perl, the given/when construct (also known as smartmatching) is an experimental feature that allows for a more readable way to perform case-switch like operations. However, when dealing with Unicode and different encodings, it is crucial to understand how smartmatching interacts with these characteristics to avoid unexpected behavior.

Here's an example of how given/when behaves with Unicode strings:

#!/usr/bin/perl use strict; use warnings; use utf8; my $input = "こんにちは"; # Japanese for "Hello" given ($input) { when ("こんにちは") { print "Matched Japanese Hello\n"; } when ("Hello") { print "Matched English Hello\n"; } default { print "No match\n"; } }

Perl given when smartmatch Unicode encodings programming scripting