[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Q: last ":" in a file path





--- begin quoted text

What's the pro and con of having a ":" in the end of a path?

In Mac scripting, path ending with ":" indicates it's a folder, but
apparently MacPerl (or Perl) doesn't care about this possibly because Unix
world doesn't care. (since in unix folder are files (or such fact made
very explicit))

For instance, the following script still works with or without ":" at the
end of path.

opendir(D,"APS600:T2:Perl files");
print join("\n",readdir(D));

Can we say that the last ":" has absolutely no meaning in MacPerl?

 Xah, xah@best.com
 http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
"New Programing Paradigm: Parallel execution of bugs and C/C++
programers."

--- end quoted text

In a sense it's meaningless, but it's always a good idea to be consistent,
and to either always use or not use the trailing :. I usually always put
the trailing : (or/ on Unix) just as a visual reminder that the path is
for a directory.

But consistency really pays off when you go to construct a longer path by
cocanctenation. Then you can change the meaning of the new, longer, path
if you're not careful. For while on Unix // is the same as /, on a Mac ::
is not the same as:. My code frequently contains things like

      $dir=~ /:$/ ? $dir.$name : $dir.":".$name;

when I can't be sure how $dir is going to end.



-------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20771
schinder@leprss.gsfc.nasa.gov


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch