in reply to Re: Get macOS Version
in thread Get macOS Version

Hi Tux, it looks like there 'osvers' also means 'build version', rather than 'OS version,' and the string that the OP needs ("10.13") is buried in the 'os' value. Of course one could fish it out of there, but in this case I think I prefer the simplicity of a shell call: qx/sw_vers -productVersion/. If the function had to be portable, I might use the module you show, but with the parsing code needed for each OS, it seems like one might as well have conditionally executed shell calls.


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^3: Get macOS Version
by Tux (Canon) on Jul 11, 2019 at 12:13 UTC

    Mea culpa, mea maxima culpa for waiting so long to implement something so simple. I needed access to a Mac to test it, but it is just released as 0.059:

    mac01 $ perl -Mblib examples/sysinfo.pl -- from methods Distname : mac01.local darwin - 17.0.0 (Mac OS X - macOS 1 +0.13 (17A365)) Mac mini (2 GHz) 1 [2 cores] x86_64 Hostname : mac01.local Number of CPU's : 1 [2 cores] Processor type : x86_64 Processor description: Mac mini (2 GHz) OS and version : darwin - 17.0.0 (Mac OS X - macOS 10.13 (17A365 +)) -- from hash cpu : Mac mini (2 GHz) cpu_cores : 2 cpu_count : 1 [2 cores] cpu_type : x86_64 distro : Darwin 10.13 hostname : mac01.local os : darwin - 17.0.0 (Mac OS X - macOS 10.13 (17A365 +)) osname : Darwin osvers : 10.13

    Enjoy, Have FUN! H.Merijn