如何判断我的Perl脚本是否在Windows下运行?

前端之家收集整理的这篇文章主要介绍了如何判断我的Perl脚本是否在Windows下运行?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Windows系统(Win9x,WinXP,Vista,Win7等)上编程确定Perl脚本是否正在执行的最佳方式是什么?

填写空白处:

my $running_under_windows = ... ? 1 : 0;

解决方法

perldoc perlvar
  • $OSNAME
  • $^O

The name of the operating system under which this copy of Perl was built,as determined during the configuration process. 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 07001 and 07002) to distinguish between the variants.

原文链接:https://www.f2er.com/Perl/171415.html

猜你在找的Perl相关文章