How can I detect the operating system in Perl?

后端 未结 11 1466
我在风中等你
我在风中等你 2020-12-04 16:41

I have Perl on Mac, Windows and Ubuntu. How can I tell from within the script which one is which? Thanks in advance.

Edit: I was asked what I am doi

11条回答
  •  抹茶落季
    2020-12-04 17:06

    The variable $^O (that's a capital 'O', not a zero) holds the name of the operating system.

    Depending on what you want, it may or may not give the answer you want - on my system it gives 'linux' without saying which distro. I'm not so sure about what it says on Windows or MacOS.

提交回复
热议问题