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

I am trying to escape spaces in a filename so I can use then file in File::* modules. I find that some modules do it for you and others don't. The reg-exp I came up with looks like this:
s/\ //\\ /g;
This gives me two back slashes which I don't want. Any suggestions.

Replies are listed 'Best First'.
•Re: escaping filenames
by merlyn (Sage) on Jun 19, 2002 at 21:16 UTC
      OK File::Copy you don't need to escape filenames, but File::NCopy, and File::Remove you do. So what is the best way to escape filenames. There must be a regular expression that will do everything. On an unrelated topic, how do I move a directory and all of its files to a new destination without doing a system call, or copying the tree and deleting the tree as I am doing now. I can't seem to find a move or rename perl function to do it. Any suggestions?