Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

OS Info

by Anonymous Monk
on Feb 07, 2003 at 08:43 UTC ( #233398=perlquestion: print w/replies, xml ) Need Help??

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.


      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";

    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

    Also mirrored at

    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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://233398]
Approved by pfaut
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-05-25 13:57 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (90 votes). Check out past polls.