i use Suse Linux.

i wanna copy all files listed in file:list4, but they are Chinese files with Chinese file names.

variable $1 and $2 are direcory names, and $3 is the Chinese file name.

almost half of the files are copied successfully, with the code as the follws :

system("cp $spath$1/$2/$3 $tpath$3");

however, if there are space,quotes, brackets, or dash lines in the file names, then the above code won't work.

if i add double quotes to variable $3, like :

system("cp $spath$1/$2/"$3" $tpath$3");

the syntax error messages are :

(Missing operator before $3?)

(Missing operator before " $tpath"?)

so,execution aborted due to compilation errors.

is there anyway to copy files with Chinese names and special characters in Suse Linux?

Thanks for any advise in advance !

-- Anne

<code> #!/usr/bin/perl use Cwd; use strict; use utf8; my $tpath="/tmp/ttmp/"; my $spath="/opt/myfirstbank/uploadDir/"; open(F,"list4") or die "Cannot open list2. $!\n"; while (<F>) { $_=~/^(.*?)\/(.*?)\/(.*?)\s/; system("print $1/$2\n"); system("cp $spath$1/$2/"$3" $tpath$3"); } close F;

In reply to How to copy files with Chinese names and special characters in Suse Linux? by anne3294

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.