http://qs321.pair.com?node_id=330538


in reply to "Porting" scripts to Win32

I routinely use perl on a Win XP box at work (at home I run Mac OS X) so I can offer a few pointers.

Unfortunately, just like the different versions/vendors/flavors/variants of Unix, Windows directory layout also varies from OS version to version. But, it is mostly quite predictable. And most system directories can be addressed by variables. I have never used Windows system variables in perl scripts, but it would be interesting to see if they work... they are usually surrounded by % signs such as %TEMP% or %SYSTEM% etc.

The ~/.app-name is actually followed, but it is not OS mandated but application specific. Of course, directories or files starting with a . are not invisible.

On Win XP there is a convolutedly named "Documents and Settings" folder on the C root where such things get stored usually, and under that folder is also an Application Data (I think that is what it is called) folder where app specific detritus can be stored such as mozilla prefs, etc.

You don't really have to hack the registry as it is mostly for system specific things such as asscoiating all .pl or .plx extension files with the perl binary so you can actually run those files by double-clicking on them.

Most config files get stored under the Winnt directory and they usually end with the .ini suffix.

Hope some of this helps. But you definitely will have to explore the various versions of Windows to figure out if your scripts are going to be affected. Alternatively you could run a config script that asks the user a few questions and makes its settings, but most users are not likely to know what goes where. Or, you could just make up your own tmp directory, store stuff there, and blow it away when the script is done (or not, if you want the settings to persist).

Since I have never needed to mess with those kind of things, I have found that my scripts run mostly without any changes and without any problems (except for changing the shebang line, of course when moving from Mac OS X to Win and back. If I have to store anything, I usually create a directory under my scripts directory where I can write stuff.