Well I think you should look into John M. Dlugosz suggestion. Using an API call to do this has got be better than calling ver through a backtick or system() call. On the subject of windows resources though I would strongly suggest you check out www.sysinternals.com probably the most useful set of windows power tools. (I exclude cygwin on purpose :-)

But no matter what you do I cant help but saying that some of your regexen worry me a bit. Like for instance you are using dot unescaped. Personally I might try to come up with a regex that pulled apart the various version strings and then looked them up in a hash. Something like

local $,="\t"; while (<DATA>) { /Windows\s(\w+)\W+Version\s((?:\d+\.?)+)/ && print $1,$2,"\n"; } #Outputs # 98 4.10.1998 # 2000 5.00.2195 # 95 4.00.1111 # NT 3.51 # NT 4.0 __DATA__ Windows 98 [Version 4.10.1998] Microsoft Windows 2000 [Version 5.00.2195] Microsoft Windows 95. [Version 4.00.1111] Windows NT Version 3.51 Windows NT Version 4.0
Now you have WinType and WinVer as $1 and $2 respectively. Anyway just thought it needed to be said.

:-)

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)


In reply to Re: Windows Version Detection by demerphq
in thread Windows Version Detection by jlongino

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.