in reply to Re^3: Win32 File tests, pathnames
in thread Win32 File tests, pathnames

Well, I put together some sample code, and OK, it reads a pathname with single slashes, and seems to run it ok, except for a 'Can't spawn "filename-here" No error" after executing the command.

What I was getting at was that, since so many of the docs for Win32 modules have double slashes instead of single slashes, if I were to follow that convention, I'd have to convert back and forth between single and double slashes. An example, taken from from the Win32::AdminMisc FAQ:

Win32::AdminMisc::ComputerAliasAdd( '\\\\Server1', 'fred' );
and another example from the Win32::FileOp page:
Substed 'A:' => ('','Floppy0') Substed 'B:' => undef Substed 'C:' => ('','Harddisk0\Partition1') Substed 'H:' => ('\\\\servername\homes\username','UNC') # set by subst H: \\servername\homes\username Substed 'S:' => ('\\\\servername\servis','LanmanRedirector') # set by net use S: \\servername\servis Substed 'X:' => () # not mapped to anything
You will notice that these, and other cases, have four slashes, not two, at the beginning of a UNC path.

So, basically, I'm worried that somewhere along the line, I'll get the two mixed up. A potential ramification here is that the config file could be written with four slashes and not two for a UNC path. Of course, there are other bugs that could pop up, too...

-- Burvil

Replies are listed 'Best First'.
Re^5: Win32 File tests, pathnames
by GrandFather (Saint) on Apr 06, 2006 at 02:17 UTC

    The bottom line is that for your users the "documentation" that they will most often use is the existing contents of the configuration file. They should never need to see the Perl nor the module documentation to configure the system, so the issue of quoted / in the configuration file should never arrise.

    A trick that you could use is to replace / with \ everywhere in your source, then normalise the paths by replacing / with \ at the "last minute". The configuration file isn't affected and you don't need to worry about quoting \ in your code (except in the normilisation routine). Note that a lot of modules are pretty blase about the difference between \ and / in files paths so normalising as a last step is often a good idea in any case.


    DWIM is Perl's answer to Gödel