On May 31, 2004, at 12:50 PM, Ian Ferguson wrote:

That seemed to fix it, but the escaped version still is not recognized.

It's not supposed to be recognized. Escapes are necessary in a shell, because it uses white space as a delimiter, so white space that isn't to be treated as such needs to be escaped.


I guess that this is a good time to ask whether or not Perl requires me to
quote paths containing spaces

No, it doesn't. Is this a good time to ask what led you to believe it might, or should? ;-)


or if it is smart enough to resolve things on its own.

There's nothing to resolve. The file name is (for example) "file name space.txt". When you use that in a shell without escaping the spaces, the shell splits it up into three separate arguments: ("file", "name", "space.txt"). To prevent it from doing that - i.e. to tell the shell that the spaces are part of a single argument, not delimiters between multiple arguments - you escape the spaces.


In Perl, strings are most often delimited by single- and double-quotes, not spaces. So spaces don't normally need to be escaped. But see 'perldoc perlop' - especially the "Quote and Quote-like Operators" section. The point of having a variety of quote operators is to allow you to choose a delimiter that doesn't appear in the input and thus doesn't need to be escaped.

For example, if I had assigned $dir =
"/Users/my_username/Desktop/with spaces/" and then I was to rmdir( $dir )
would this cause a problem or should I quote the variable rmdir( "$dir" )?

It's unnecessary, and some members of the Cranky Perl Police will chastise you for it. (See <http://tinyurl.com/2l6wm>). It *is* slightly inefficient - a temporary string is created, and then $dir is interpolated into the temp string - but the CPP makes entirely too big an issue of it.


sherm--



Reply via email to