I am creating a small perl script on Windows.
I want to determine the version of Windows i.e. XP, Vista, 7, 8, etc.
How can I get this information?
Thank You.
UPDATE: I want to know the Version of Windows on which the script is running!
Please add some code on how to use the API's as I am a beginner & dont know much about perl.
Try Win32:
#!/usr/bin/env perl
use 5.014;
use strict;
use warnings;
use Win32;
say Win32::GetOSDisplayName();
say for Win32::GetOSName();
say for Win32::GetOSVersion();
If that is not sufficient, you can call GetVersionEx via Win32::API.
From http://perldoc.perl.org/perlvar.html
$^O
The name of the operating system under which this copy of Perl was
built, as determined during the configuration process. For examples
see PLATFORMS in perlport.
The value is identical to $Config{'osname'}
. See also Config and the -V command-line switch documented in
perlrun.
In Windows platforms, $^O is not very helpful: since it is
always MSWin32 , it doesn't tell the difference between
95/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or
Win32::GetOSVersion() (see Win32 and perlport) to distinguish between
the variants.