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?
|