in reply to dealing with cyrillic characters

Hi. Your text files are probably encoded in UTF-8. So you need to tell this to Perl, and in particular to File::Slurp. You can do this simply replacing your line

my $string = read_file($file); with my $string= read_file( $file, binmode => ':utf8' );

This requires your file to be in UTF-8. You should be able to change the "utf8" with the encoding of your text. You can check this using simply a Text Editor like Notepad++

Replies are listed 'Best First'.
Re^2: dealing with cyrillic characters
by Aldebaran (Curate) on Jun 22, 2018 at 17:43 UTC

    Wow, thanks, it was that simple a fix. I got everything I wanted by setting the binmode to utf8 on File::Slurp. I looked on gedit to see what encoding the underlying text files might have and was unable to ascertain it. That I can read the cyrillic makes me think it is indeed utf8. Relevant code:

    improved page I budgeted all day to figure this out, so I'm gonna go form some concrete. большое спасибо снова.

      The AM already provided a link to File::Slurp is broken and wrong. I suggest you use this instead (as just discussed here):

      my $string = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> };