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

Re: [MacPerl] How do you... solve the pathname problem?



Peter Prymmer writes:
|But to merely go from UNIX to Mac style it is still pretty simple to 
|write some regex[e|p]s on the fly:
|  $mac_spce = $unix_spec;
|  $mac_spce =~ s#\/#:#g;

If you have control over and can severely limit the paths you're using,
these work fine, but if you want to deal with general paths, you run into
problems. Consider a//b, a/./b, a/../b, a:b, //a, /./a, /../a, and
combinations thereof.

It may be possible to come up with an r.e. that handles all of those
(although I kind of doubt it), but I find it easiest to split the Unix
path on /, then examine each element one at a time, and push appropriate
elements on a second array, which is then joined to become the Mac path.

Brian

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