#!/usr/bin/perl %trans = ( "t'i" =>'ти', "t'a" =>'тя', "t'u" =>'тю', "t'e" =>'те', #It continues like this for several hundred lines, this is just a snippet. So it just goes through all character combinations and turns the text to cyrillic. ); # Actual Translation Logic: @signs = sort {length($b) <=> length($a)} keys %trans; @signs = map quotemeta($_), @signs; $re = join '|', @signs, '.'; # Read Input from Stdin - one line at a time while () { $input = "$_"; $input =~ s/($re)/exists($trans{$1}) ? $trans{$1} : $1/geo; print $input, ""; } #### menö šuöny niko at't'ö perl manastyrly! #### menö šuöny niko #### #### менӧ шуӧны нико аттьӧ перл манастырлы!