开发者

How to write cross-platform perl code

A perl script which would include di开发者_JAVA技巧fferent modules for both Windows and Linux, In order to make it cross-platform, I want someway to implement it, just like in C++:

#if _WIN32
//...
#else
//...
#endif


if, $^O:

use if $^O eq 'MSWin32', Win32::Console::ANSI::;

Alternatively,

use Win32::Console::ANSI ();

is equivalent to

BEGIN {
    require Win32::Console::ANSI;
}

so you could also use

BEGIN {
    require Win32::Console::ANSI
        if $^O eq 'MSWin32';
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜