Okay, I did some research (using google mostly) and I found that I do indeed have all the right numbers.
And now that I am at home where I have Win 2k, I see that $build is now correct... Can anyone confirm that it is only correct on NT based systems?
I have also taken
jeffa's advice and used a lookup table. But, I extended what he wrote a little. Here is the latest version:
#!/usr/bin/perl
use strict;
use warnings;
use Win32;
my ($string, $major, $minor, $build, $id) = Win32::GetOSVersion();
my %lookup = (
1 => {
4 => {
0 => 'Win 95',
3 => 'Win 95 OSR2', # this is new!
10 => 'Win 98',
90 => 'Win ME',
},
},
2 => {
3 => {
51 => 'Win NT 3.51',
},
4 => {
0 => 'Win NT 4.0',
},
5 => {
0 => 'Win 2k',
1 => 'Win XP',
},
},
);
my $os = $lookup{$id}->{$major}->{$minor};
$os ||= 'Unknown Win32s flavor';
print "$os, $major.$minor, build $build";
print ", $string" if ($string ne "");
print "\n";
BEGIN {
if ($^O !~ "Win32") {
print "This is not a Win32 system. Exiting...\n";
exit;
}
}
Updated the code to display build number and $string...
Who says that programmers can't work in the Marketing Department?
Or is that who says that Marketing people can't program?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.