Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have some strange result in my script, where I am using Russian characters from UTF-8. If I do it this way, it works:
#!/usr/bin/perl use strict; use warnings; my (@kmap, @rmap, %map); { no warnings; # Не хуя в +опить @kmap = qw/A B V G D E + J Z I Y K L M N O P R S T U F H C X ! @ # + $ % ^ & * a b v g d e = j z i y k l m n o p r s t u f h c x 1 2 3 4 +5 6 7 8/; @rmap = qw/А Б В Г Д Е Ё +; Ж З И Й К Л М Н  +054; П Р С Т У Ф Х Ц +Ч Ш Щ Ъ Ы Ь Э Ю k +1; а б в г д е ё ж &# +1079; и й к л м н о п + р с т у ф х ц ч 
 +96; щ ъ ы ь э ю я/; } @map{@kmap} = @rmap; my $c; for (@kmap){ print "$_: $map{$_}\t"; print "\n" unless ++$c % 9; }
Output:
A: А B: Б V: В G: Г D: Д +E: Е +: Ё J: Ж Z: З I: И Y: Й K: К L: Л M: М +N: Н O: О P: П R: Р S: С T: Т U: У F: Ф H: Х +C: Ц X: Ч !: Ш @: Щ #: Ъ $: Ы %: Ь ^: Э &: Ю +*: Я a: а b: б v: в g: г d: д e: е =: ё j: ж +z: з i: и y: й k: к l: л m: м n: н o: о p: п +r: р s: с t: т u: у f: ф h: х c: ц x: ч 1: ш +2: щ 3: ъ 4: ы 5: ь 6: э 7: ю 8: я
But, if I do it this way:
#!/usr/bin/perl use strict; use warnings; my (@kmap, @rmap, %map); { no warnings; # Не хуя в +опить @kmap = split //, 'ABVGDE+JZIYKLMNOPRSTUFHCX!@#$%^&*abvgde=jziyklm +noprstufhcx12345678'; @rmap = split //, 'АБВГДЕf +5;ЖЗИЙКЛМНО
 +55;РСТУФХЦЧШ +065;ЪЫЬЭЮЯабв&# +1075;деёжзийкл& +#1084;нопрстуфх +цчшщъыьэюя +;'; } @map{@kmap} = @rmap; my $c; for (@kmap){ print "$_: $map{$_}\t"; print "\n" unless ++$c % 9; }
then the output looks like this:
A: �B: � V: �G: � D: �E: A +533; +: �J: � Z: � I: � Y: �K: � L: �M: � + N: �O: � P: �R: � S: �T: � U: �F: � H: �C: A +533; X: �!: � @: � #: � $: �%: � ^: �&: � + *: �a: � b: �v: � g: �d: � e: �=: � j: �z: A +533; i: �y: � k: � l: � m: �n: � o: �p: � + r: �s: � t: �u: � f: �h: � c: �x: � 1: �2: A +533; 3: �4: � 5: � 6: � 7: �8: �
Why the difference?
(I see from preview that it is not showing the characters. The first output is English and Russian mapping; the second is English and question marks in ovals instead of Russian letters, and the output is not well aligned.)
|
|---|