This meditation mentions just a few thoughts about an aspect of using Perl on MSWin that has been periodically coming up in discussions on the chatterbox. That aspect is the presence or absence of embedded spaces in file pathnames. One can pretty much assume that others will have differing opinions from what I present here, hopefully someone will find it useful all in all.
First of all, I'm going to make the most common distribution of Perl for MSWin-32bit the reference point for this presentation. ActiveState's ActivePerl has its detractors and fans, but it is the decendent of the original port of modern Perl 5 for MSWin (done by Gurusamy Sarathy who is TTBOMK still employed at AS).
Just to get the edge sharpened on this point about file pathnames with embedded spaces I'll quote verbatim here from a message embedded in the file Installer.bat that comes in the AP (ActivePerl) .zip "DARF" (Distribution ARchive File):
Looks like you are trying to install Perl into a path that contains spaces or other special characters. Though the latest Windows operating systems claim to support filenames with such special characters, many existing utilities will have trouble with such path names. Chances are that you will find this is simply too much of a bad idea to be worth it.If this is representative of the information commonly disseminated about spaces in pathnames then it is no wonder there's widespread confusion. That's a pretty confusing message! "the latest Windows operating systems claim to support filenames with such special characters ..." means what exactly?!? That MS is lying about how their OS's work? That it's the OS's fault if something breaks in Perl or in something one tries to do with Perl, if there are embedded-space pathnames involved? I am not sure. This is probably an instance of poor-quality user documentation that ActiveState should have improved a long time ago, but leaving that point aside for a moment, it still seems reasonable to take it as a warning that relying on workability when Perl is installed to a pathname location with embedded spaces is asking for trouble down the line. It might furthermore be taken as a warning that when you are doing things with Perl on MSWin, blithely assuming that the presence of embedded spaces will never impact anything could be a foolish complacency.
The support for spaces in pathnames in MSWin isn't really debateable. What's troublesome is what happens when a shell (command interpreter) that splits arguments on spaces is presented with a pathname argument that contains embedded space. A shell, whether it is CMD or COMMAND or something more civilized that is pronounced with a name ending in the letters "sh", has no way of knowing that you meant `C:\Program' and ` Files\' were to be understood as comprising one unit. And anytime there is a .bat (or .cmd) file involved, the shell is involved, for one thing.
Here is a partial list of the .bat files that are shipped with the AP distribution:
c2ph.bat cpan.bat crc32.bat dprofpp.bat enc2xs.bat exetype.bat find2perl.bat gedi.bat GET.bat h2ph.bat h2xs.bat HEAD.bat instmodsh.bat libnetcfg.bat lwp-download.bat lwp- mirror.bat lwp-request.bat lwp-rget.bat perlbug.bat perlcc.bat perldoc.bat perlglob.bat perlivp.bat piconv.bat pl2bat.bat pl2pm.bat pod2html.bat pod2latex.bat pod2man.bat pod2text.bat pod2usage.bat podchecker.bat podselect.bat POST.bat ppm.bat ppm3-bin.bat ppm3.bat prove.bat psed.bat pstruct.bat ptar.bat ptked.bat ptksh.bat reloc_perl.bat runperl.bat s2p.bat search.bat SOAPsh.bat splain.bat stubmaker.bat tkjpeg.bat widget.bat XMLRPCsh.bat xsubpp.bat
Some might say something like "Presumably all of these scripts are written 'defensively' so that the program will do the right thing when it encounters args or data with embedded spaces, since the distribution of these scripts to MSWin systems implies conformance with the cultural expectations of MSWin users." However it is manifestly clear from the author's experience that not much can be assumed. The `make' program (whatever flavor), for example, that one can choose to install on MSWin (since it does not ship with one), is an example of an external tool that is invoked when a CPAN module is built using the `cpan' utility. There is no way that spaces in pathnames are going to be magically handled in such a case.
I'd like to ask readers who have their own memories of experiences with a breakdown in some Perl-related endeavor caused by the presence of an embedded space in an argument or input data, to please recount what and how it went wrong, below.
Thanks!
In reply to The Evil Embedded Space by Intrepid
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |