RosettaCodeData/Task/Reverse-a-string/Perl/reverse-a-string.pl

12 lines
334 B
Perl

use utf8;
binmode STDOUT, ":utf8";
# to reverse characters (code points):
print scalar reverse('visor'), "\n";
# to reverse graphemes:
print join("", reverse "José" =~ /\X/g), "\n";
$string = 'ℵΑΩ 駱駝道 🤔 🇸🇧 🇺🇸 🇬🇧‍ 👨‍👩‍👧‍👦🆗🗺';
print join("", reverse $string =~ /\X/g), "\n";