Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Get version of installed OS

by GrandFather (Sage)
on Nov 22, 2012 at 11:48 UTC ( #1005117=note: print w/replies, xml ) Need Help??

in reply to Get version of installed OS

You can use Win32 to get the information you want then a little playing around to get a OS name:

#!/usr/bin/perl use warnings; use strict; use Win32; my %versions = ( 0 => {'' => {'' => "Win32s"}}, 1 => { 4 => { 0 => "Windows 95", 10 => "Windows 98", 90 => "Windows Me" } }, 2 => { 3 => {51 => "Windows NT 3.51"}, 4 => {0 => "Windows NT 4"}, 5 => { 0 => "Windows 2000", 1 => "Windows XP", 2 => "Windows Server 2003" }, 6 => { 0 => "Windows Vista or Server 2008", 1 => "Windows 7" } }, ); my ($name, $major, $minor, $build, $id) = Win32::GetOSVersion(); print $versions{$id}{$major}{$minor};

Actually a little more work than that is required to do a proper job, but it is well documented in Win32::GetOSVersion() docs linked above.

True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005117]
[Corion]: I spent parts of yesterday digging into Filter::Simple to make it not change the line numbers of unfiltered code, but I think I need regex help (which will come in a SoPW I guess). I tried @lines = /((?:"...."|[^" \n]+)\n)/gs, but that matched on...
[Corion]: ... foo "\0\0\0\n" bar\n by matching the first \n instead of matching the four-bytes-in- double-quotes part
[Corion]: ... and I still don't understand why ;)
[Corion]: This is because Filter::Simple does some string-trickery, replacing all string literals with "quoted packed numbers"
[Corion]: I fear this might be a bug in the RE engine, but if it is a bug, even fixing won't help me because I need Filter::Simple for Filter::signatures , which provides signatures as a backwards compatibility feature for Perl <5.22 - and these ...
[Corion]: ... won't get a fix anyway ;) My plan B is to encode the string placeholders avoiding \r and \n

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-01-23 08:06 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (191 votes). Check out past polls.