in reply to $^O eq 'Win32' is a bad idea.
in thread use Win2000; and alike

You are probably right. I have no way of testing this, but I'll start changing die if $^O eq 'Win32' to die if $^O =~ /win32|dos/i in my scripts ;) (Come to think of it, Windows.pm would allow for a nice no Windows :)

On $^O knowing the type of Windows: if I recall correctly, $^O is hardcoded into perl, and Windows 95 programs can run under Windows 2000. I may be wrong, though.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
(wil) Re: $^O eq 'Win32' is a bad idea.
by wil (Priest) on Jun 06, 2002 at 10:14 UTC
    If you need to be specific, then it might be worth looking at some special Win32 functions.

    Here's a quote from the relevant perldoc:

    Win32::GetOSVersion()
    [CORE] Returns the array (STRING, MAJOR, MINOR, BUILD, ID), where the elements are, respectively: An arbitrary descriptive string, the major version number of the operating system, the minor version number, the build number, and a digit indicating the actual operating system. For ID, the values are 0 for Win32s, 1 for Windows 9X and 2 for Windows NT. In scalar context it returns just the ID.

    You might also be interested in this recent snippet which basically formats the output of Win32::GetOSVersion().

    - wil
      Not to be snarky Wil but did you look at Determine Windows Type or Version? I dont think the author of the snippet you mention did either.. :-)

      Well, not at first he didnt anyway.

      Yves / DeMerphq
      ---
      Writing a good benchmark isnt as easy as it might look.

Re: Re: $^O eq 'Win32' is a bad idea.
by demerphq (Chancellor) on Jun 06, 2002 at 10:07 UTC
    Well, most times it is sufficient to know that you are on a Win32 box irrespective of type. So yes Win9x stuff usually works ok on W2k. But not necessarily the opposite. And when using external tools, the system directories are in different locations so on occassion it can be useful to know the difference.

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.