nikolay has asked for the wisdom of the Perl Monks concerning the following question:

Hi.

I get an error of kind "utf8 ... does not map to Unicode at ..." when i'm trying to get files list by qx#find ...# construction, in the case when the files have wrong characters (non-utf8).

I know how to redirect the output to a file and then read the files w/ the wrong encoding, pointed out, so, that i can read all the characters, and even PERL can work in the case (no die w/ an error).

The problem lays in necessity to open those files list by some other programs, ran through system() call, after some logic being done by the script on the files list. -- The PERL logic works perfect on the converted files list, as long as it comes not to the "another program call through system()" -- in which case, of course, the original (not converted) files names are necessary (or the "another program" simply does not recognize it in the FS -- that makes the "work around" profit for PERL to zero!

In other words, the PERL script would work perfectly, unless the PERL itself would not be stupid enough as to inform the user on the "mapping" -- that not user, nor "other programs" called, do not carry for, and terminate the script.

So, as i have to try to accomplish the task in PERL, what are my options regarding the matter?

- Can i straiten PERL by some magical directive as to keep simpler and perform not the tasks it is not been asked for (informing), nor terminate scripts running it (on PERL's much want, but let scripts itself decide what to do w/ the data it processes), regardless PERL poor design?

- Or there is some other trick how PERL developers do in such cases?

Thanks for any advance or idea.

  • Comment on [CLOSED] How to make PERL just execute the script until its end?

Replies are listed 'Best First'.
Re: How to make PERL just execute the script until its end?
by Corion (Patriarch) on Oct 16, 2016 at 12:43 UTC

    Why do you try to convert/read the file names from find as UTF-8? Maybe simply keeping the filenames as-is already is enough?

    See maybe binmode to make Perl not convert stuff it reads. Of course, then using UTF-8 regular expressions will stop working. If you want to mix UTF-8 and other encodings, read all data with its respective encoding. If your filesystem delivers filenames in different encodings, clean up your filesystem.

      Yes, i need process the filenames in PERL and return it to FS back. In order to clean my FS i have to process the files -- since the original question comes up.
Re: How to make PERL just execute the script until its end?
by nikolay (Beadle) on Oct 17, 2016 at 06:37 UTC

    I have found the solution myself -- i need to decode (for the PERL pocessing) and encode back (for outer programs) the filenames.

    So, the topic is closed now.