加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 22:03:07 所属栏目:大数据 来源:网络整理
导读:在 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 cop
在 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读