use utf8;#no change if I use this or not

From the documentation for the utf8 pragma (original emphasis retained):

Do not use this pragma for anything else than telling Perl that your script is written in UTF-8.

So, if you script includes the UTF-8 string "сервис.pdf", you should use it; if it contains "xyz.pdf" (or whatever), you don't need it.

The thing to check here would be whether you've actually included "сервис.pdf" as a UTF-8 string. If you've used some other encoding, that may be the cause of whatever issues you're encountering.

You haven't shown the assignment to $DocumentPath in your code; nor have you actually said what problems you're experiencing: "How do I post a question effectively?" provides guidelines on what information to include with your question such that we can better help you (as an example, whatever value $! holds may be useful).

I'm wondering if whatever encoding your MSWin setup uses is behind the problem: you're passing cyrillic from Perl; MSWin sees that as something completely different. I don't have that available to test — I have:

$ perl -v | head -2 | tail -1 This is perl 5, version 26, subversion 0 (v5.26.0) built for darwin-th +read-multi-2level

However, I can confirm that what you're attempting, has no basic flaws with respect to cyrillic. Here's a little test one-liner (which I've split over several lines for ease of viewing):

$ perl -E '
    use utf8;
    my $f = "сервис.pdf";
    my @c = (ls => $f);
    if (-e $f) {
        system @c
    }
    else {
        say 0
    }
'

Here's some test runs, with that one-liner reduced to just "perl -E '...'".

$ perl -E '...'
0
$ > сервис.pdf.
$ perl -E '...'
сервис.pdf
$ rm сервис.pdf
$ perl -E '...'
0

[In case you're unfamiliar with those commands, ">" is just creating an empty file with the name given and "rm" removes (deletes) it.]

Posting non-ASCII code and data can be an issue. I try to keep it to a minimum. When it is needed, I use <pre>...</pre> instead of <code>...</code> for blocks; and <tt>...</tt> instead of <c>...</c> within paragraphs. You also need to replace special characters with entities (e.g. s/&/&amp;/, s/>/&gt;/, etc.), which is another reason to keep it minimal: there's a list of those entities right after the textarea where you compose your node.

One final point, system takes a list of arguments. Of course, that list could consist of a single string; however, there's no need to programmatically concatenate the arguments into a single string. See @c in my code above.

Update: Oops! Changed "replace entities with special characters" to "replace special characters with entities".

— Ken


In reply to Re: Non asci character and system call by kcott
in thread Non asci character and system call by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.