magine two simple variables with Unicode text in it. And you print those variables to standard output. What may be easier?..
#!/usr/bin/perl
my $ustring1 = "Hello \x{263A}!\n";
my $ustring2 = <DATA>;
print "$ustring1$ustring2";
__DATA__
Hello ☺!
You could apparently fix things by avoiding concatenation:
#!/usr/bin/perl
my $ustring1 = "Hello \x{263A}!\n";
my $ustring2 = <DATA>;
print $ustring1, $ustring2;
__DATA__
Hello ☺!
There is a distiction between bytes and characters. Characters are Unicode characters. One character may be represented by several bytes, when stored, printed or sent over network. That depends on a particular encoding used. UTF-8 is just one of the ways to do represent Unicode data.
Perl has a “utf8” flag for every scalar value, which may be “on” or “off”. “On” state of the flag tells perl to treat the value as a string of Unicode characters.
If you take a string with utf8 flag off and concatenate it with a string that has utf8 flag on, perl converts the first one to Unicode.