Were I to hazard a guess, I would say it is the fact that the Windows CMD prompt does not understand '/' as a path separator; instead, it uses '\' (which most things with a *nix background -- including C and perl -- use as an escape character). In order to include a '\' in a string, you would need to use "\\", or a '\' in a single-quoted string. You can also use the q or qq operators as a way to quote the string. ('q//' is a way to represent a single-quoted string, and 'qq//' a double-quoted string.)

# Replace assignment with this. # 'q//' treats as a single-quoted string, which does not try to # interpolate characters. As a result, the double-quotes in # the command do not require escaping. Here I used the '/' as # the delimiter for the single-quoting 'q', but could be other # characters depending on what is needed in the string. I also # used the '.' to concatenate the string, allowing it to be # written across multiple lines so the spaces between parameters # were obvious. my $cmd = q/fsutil/ # command . q/ / . q/file/ # parameter 1 . q/ / . q/setShortName/ # parameter 2 . q/ / . q/"C:\Users\James\Music\國語懷念&# +32769;歌 Vol. 2"/ # parameter 3 . q/ / . q/"Vol2~00A"/; # parameter 4 # The double-quotes in parameter 3 are necessary # due to the spaces within the file name. # Continue remainder of code as before

Hope that helps.


In reply to Re: Problem running shell command from Perl by atcroft
in thread Problem running shell command from Perl by CrashBlossom

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.