优雅确定系统架构中的Perl [英] Elegantly Determining System Architecture Within Perl

查看:65
本文介绍了优雅确定系统架构中的Perl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个简单的方法来确定系统是否是32位还是64位在Perl 5中我已经向后阅读 perlvar 手册页和前锋,并没有发现,包含系统的CPU架构(CPU的架构的Perl编译为会非常接近)的变量。这是我来最接近的:

I'm looking for a simple way to determine whether a system is 32- or 64-bit from within Perl 5. I have read the perlvar manual page backwards and forwards, and have not discovered a variable that contains the system's CPU architecture (the CPU architecture Perl was compiled for will come close enough). This is the closest I have come:

chomp (my $arch = `uname -m`);

我不知道是否有这个决定的更优雅的方式;我讨厌依靠反引号前pressions,因为他们都是一个瓶颈,往往是不安全的,而且经常(本例中特别是)打破跨平台兼容性。我们没有理由不Perl的应该已经拥有这些信息。

I was wondering if there was a more elegant way of determining this; I hate relying on backtick expressions, as they are both a bottleneck, tend to be insecure, and often (this example especially) break cross-platform compatibility. There is no reason Perl shouldn't already have this information available.

推荐答案

查看 配置 模块。

也许检查是否 $ {配置archname64'} 设置就足够了。

Maybe checking whether $Config{'archname64'} is set would be sufficient.

这篇关于优雅确定系统架构中的Perl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆