现在的位置: 首页 > 综合 > 正文

The meaning of $^O in perl5

2013年12月11日 ⁄ 综合 ⁄ 共 1470字 ⁄ 字号 评论关闭
$^O


The name of the operating system under which Perl was built. The values of $^O can be insistent.

Inconsistencies


The "name" is sometimes very specific and sometimes rather indistinct. Unixen are identified by their variant (ie. aix or darwin or freebsd) making figuring out if you're on a Unix system difficult. Conversely, all versions of Windows are simply identified as MSWin32 and further contortions are necessary to figure out if you're on Windows 3.1, 95, NT, XP or whatever.


The value of $^O is usually lower case but sometimes isn't as in the case of MSWin32, MacOS, VMS and NetWare.

Identifying specific operating systems

Unix


Unixen are identified by their variant, so identifying simply that you're on a "Unix" system can be tricky. See Unix for how to solve this.

OS X

MacOS refers to Mac OS 9 and earlier. darwin refers to Mac OS X.

Windows


All versions of Windows are simply referred to as MSWin32. Further divination is necessary to determine what version of Windows you are using. See perlport for details.

VMS

VMS is identified as VMS in all uppercase.

Abuses


$^O is often used to make sweeping generalizations about the user's
environment. For example, it is assumed that all Unixen will be on a
case-sensitive file-system while it's possible that Perl is being run
on a case-insentitive filesystem mounted on a Unix system. (Mac OS X
running on an HFS filesystem is probably the most likely example of
this.) It is also used to make assumptions about what executable tools
are available such as compilers and build tools.


It is better to probe for these directly or use the values in %Config. ExtUtils::CBuilder provides a way to abstract compilation.

See Also

抱歉!评论已关闭.