logo       

Re: n00b needs help with file arguments: msg#00060

Subject: Re: n00b needs help with file arguments
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--




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe