http://qs1969.pair.com?node_id=233398

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can I determine whether my AS 5.6..1 script is running under MSWin32 NT/2000/XP or MSWin32 95/98 etc?

use Config; print @Config{qw/osname archname/};

gives me the same info in both cases.

Replies are listed 'Best First'.
Re: OS Info
by ajt (Prior) on Feb 07, 2003 at 08:49 UTC

    Hi Anon,

    Try the following thread of nodes Which flavor of Win32? there are some clever and very detailed answers in there.


    --
    ajt

      Thanks. That's perfect.

        The simplest way is to use Win32::GetOSVersion() or Win32::GetOSName()

        --- demerphq
        my friends call me, usually because I'm late....

Re: OS Info
by helgi (Hermit) on Feb 07, 2003 at 14:29 UTC
    Here's one way:
    use warnings; use strict; use Win32; my ($servicepack,$major,$minor,$build,$id) = Win32::GetOSVersion; my $os; my $version = $major+($minor/10); $version = sprintf "%2.1f", $version; if ($id == 0 ) { $os = "Win32s"; } elsif ($id == 1 ) { $os = "Win95"; } elsif ($id == 2 ) { $os = "WinNT"; } else { $os = "Unknown"; } print "You are running $os version $version with $servicepack\n";

    --
    Regards,
    Helgi Briem
    helgi AT decode DOT is

Perl $^O values for various operating systems
by PodMaster (Abbot) on Feb 07, 2003 at 14:39 UTC
    I referred to the following table a bunch of times, it ought to be posted around here just in case it disappears from alma.ch.

    Also mirrored at http://crazyinsomniac.perlmonk.org/perl/misc/perloses.htm.


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.