Here is the script text:

#!/usr/bin/perl -w print "Укажите путь к файлу: "; chomp ($put = <STDIN>); open (FILE, "$put") || die $!; @text_fila = <FILE>; close (FILE); open (FILE2, ">>/tmp/w.kr") || $!; foreach $stroka (@text_fila) { @mnogo_sim = split (//, $stroka); foreach $zn (@mnogo_sim) { $zn2 = ord ($zn); $zn2 = (((($zn2)**4) + 49)*4/17)-6; $zn2 = $zn2." "; push (@str2, $zn2); } push (@str2, "\n"); print FILE2 @str2; @str2 = ""; } close (FILE2); open (FILE, "/tmp/w.kr") || die $!; @stroka_kod = <FILE>; close (FILE); open (FILE2, ">>/tmp/e") || die $!; foreach $stroka2 (@stroka_kod) { @sim_kod = split (/ /, $stroka2); pop @sim_kod; foreach $sim (@sim_kod) { $sim = ((($sim+6)*17/4)-49)**(1/4); $sim_or = chr ($sim);; print $sim,"\t",$sim_or,"\n"; } } close (FILE2); 

What are we doing? Create a text somewhere, such as a1 \ enter \ ab2 \ enter \ abc3 \ enter \ abc4, and specify the path in the script. It encodes the text (this is its purpose) and saves the file in encoded form. Then decodes and displays on the screen. When it works fine, it will return the source text before encoding. But when performing it does not understand the bug. In particular, the "49" digit "1", "50" - that is, "2" is also displayed as "1", "51" as "2", check for yourself. I can not understand why. The formula is working, it works separately from the script. The script is not completed, but its meaning is encryption of the text, and then decryption. The path of the file at the output does not matter, I just put / tmp, so as not to litter you.

    1 answer 1

    It seems to me that the functions chr, ord and other single-byte, in our century, unicode and other two-and more byte ones should be thrown out to the dump.

    Either make the script environment (locale) forcibly one-byte.

    • What is it like? Explain - Asid
    • What how? how to set the locale? Google knows