分享
 
 
 

Perl/TkFAQ-12.9如何了解我所使用的Perl/Tk的版本?

王朝perl·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

原文:

12.9. How do I determine the version of perl/Tk that I am running?

With an up to date perl installation one may query the local perl setup and all extensions via the command: perldoc perllocal

For the Tk extension: version numbering has changed recently and determining the version of perl/Tk that you are running now depends on what version you are running:

Tk-b10++:

Tk-b10 (and higher) has changed to $Tk::VERSION (rather than the older "$Tk:Version") to be consistent with other packages. Hence a short succinct way to tell which version you have installed (that works with Tk-b11 and Tk400.200) is: perl -MTk -e 'print $Tk::VERSION."\n"'

Tk-b9.01:

The version numbers as of Tk-b9.01 are stored in the following variables: Core Tk version : $Tk::version Tk patchLevel : $Tk::patchLevel library : $Tk::library perl/Tk Version : $Tk::Version

At your shell prompt you could say something like the following to determine you perl/Tk Version: perl -e 'use Tk; print "$Tk::Version\n";'

The switch to Tk-b9.01 from previous versions included a large number of method name changes. Nick was kind enough to include a b9names script in the distribution that assists with the job of updating your older scripts. See the b9names script for a rather complete discussion of the name changes. Geoffroy Ville also posted a notice of some of the changes. Here is a brief (and very incomplete!) summary: older Tk-b9.01++packslaves pack('slaves')packpropagate pack('propagate')packForget pack('forget') pack('info')$w->delete if ($w); $w->destroy if ($w);

Tk-b8(--):

A little script (Tk_module) can tell you and return the value: #!/usr/bin/perl use Tk; local(*Tk_m) = \$Tk::Tk_module; print "$Tk_m\n";

Or more succintly say something like the following (at your shell prompt): perl -e 'use Tk; print "$Tk::Tk_module\n";'

You can obtain the version of Tk in use with the following (at your shell prompt): perl -e 'use Tk; print "$Tk::tk_version\n";'

where this command returned "4.0" when the previous one (or Tk_module) returned "b8".

All Tk versions:

Don't forget that you can always determine your Perl version/patchlevel/etc. with: perl -v

(at the shell prompt - it's actually a little harder to get as much information from within a #!script.) As of perl 5.002 you can use perl -V to determine your perl Configuration.

OZAWA Sakuro mailtp:ozawa@prince.pe.u-tokyo.ac.jp points out some ways to do it in a script:

1. '$]' holds the version number.

2. In Perl5, 'require NUMBER;' will complain if version is younger than NUMBER. (e.g. require 5.001;)

3. Of course, newly imported (and incompatible) features in newer scripts will bailout before execution if parsed by an old interpreter.

Note that if you use English; then $PERL_VERSION holds the version number.

To determine your MakeMaker version number try something like this (5.002): perl -MExtUtils::MakeMaker -e 'print "$ExtUtils::MakeMaker::VERSION\n";'

or this (5.001m ok): perl -e 'use ExtUtils::MakeMaker;print"$ExtUtils::MakeMaker::VERSION\n";'

or even this (older perls and MakeMakers): perl -e 'use ExtUtils::MakeMaker;print"$ExtUtils::MakeMaker::Version\n";'

Please note that thoughout this FAQ document there are references to things like Tk-b10(++) or Tk-b10++ which roughly translated to use English; means something like "I think this will work with this version of Tk and (maybe) higher versions...". You might also see Tk-b8(--) which means something like "it worked with that old version and probably worked with prior versions and if you are stuck with an old Tk version you might have to do it this way...".

译文:

12.9 如何了解我所使用的Perl/Tk的版本?

如果你的系统上已经安装了新近版本的Perl,那么你可以通过如下的命令行操作来查询你的本地Perl所安装的扩展模块情况:

perldoc perllocal

而对于如何知道Tk模块的版本,因为它的设置随其版本的不同而有一些变化,所以需要依各种情况而定。(译者注:因为这个FAQ创作的年代比较早,所以有些内容已经过时了。据我所知,目前CPAN所提供的Perl/Tk的版本都是8.0以后的。因此,这里我们略去了那些关于老本版的内容。)

对于Perl本身的版本,修订号等等的信息,我们可以通过在命令行中使用:

perl –v

来获得。而对于5.002以后的Perl版本,还可以使用perl –V来了解Perl的配置情况。

OZAWA Sakuro给出了一些可以在脚本中用来测试Perl版本的方法:

1.内置变量$]即为Perl的版本号;

2.在Perl5中,使用语句’require XXX(数字);’将会在Perl版本低于XXX时报错;

3.当然,如果你在脚本中使用了一些新引入的特性,那么做老的Perl解释器下运行时也会报错的。

对于目前广泛使用的Perl/Tk,我们可以在命令行中使用如下的简单方法来获得其版本号:

perl -e "use Tk; print $Tk::VERSION;" (Windows系统)

perl -e 'use Tk; print $Tk::VERSION;' (Unix/Linux系统)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有