王朝网络
分享
 
 
 

Perl/TkFAQ-17.3.有专门Perl/Tk的调试工具吗?

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

原文:

17.3. Is there a debugger specifically for perl/Tk?

Not for the latest version - but the -w switch and use strict; are always helpful with debugging as they provide informative error messages.

You can, of course, run under the standard perl debugger using the -d switch like so: perl -d myscript

But it is recommended that you set you breakpoints carefully since just the calls to ManWindow->new require many steps.

(Older information): Gurusamy Sarathy mailto:gsar@engin.umich.edu had built a PERL5DB file called Tkperldb (which despite the name is for pTk not Tk/perl). One must install an early de-bugger then apply a patch to bring the debugger up to date. The early debugger kit was available from: ftp://ftp.perl.com/pub/perl/ext/TK/

And Gurusamy Sarathy notes that the patch to bring the debugger up to date is available at: You need a post 5.001m perl that has support for debugging closures. Or you can simply apply: http://www-personal.umich.edu/~gsar/ to 5.001m. (5.002beta includes all the fixes in the above patch).

Note that a perl debugger may be invoked within your script with a line like: $ENV{'PERL5DB'} = 'BEGIN { require Tkperldb }';

See man perldebug(1) for more help.

Keep in mind that you are programming in perl after all. The perl debug line mode is available to you through executing the following from your shell: perl -de 0

Whereupon you must enter all the lines of a script including use Tk;. (Fancier file reads & evals are possible - but if you are getting that sophisticated why not create your own custom PERL5DB file?) When using perl -dwe 0 beware of the emacs like line editing under this debugger, and be forewarned that as soon as you type in the MainLoop; statement perl will no longer read from <STDIN>.

Ilya Zakharevich <ilya@math.ohio-state.edu> points out that very recent perldb versions will allow for simultaneous X and STDIN reads. He also points out: Note that you may use sub myLoop { if (defined &DB::DB) { while (1) { # MainWindow->Count Tk::DoOneEvent(0); } } else { MainLoop; } }(and I hope the analogous provision will be in MainLoop in tk-b9 - hi, Nick ;-)

译文:

17.3. 有专门Perl/Tk的调试工具吗?

最近的版本中还没有——但是-w开关和use strict;语句的运用是会对程序的调试很有帮助的,因为他们可以给出详细的出错信息。

当然,你也可以使用标准的perl调试开关-d,方法如下:

perl –d myscript

但是,建议大家小心的设置调试的断点,因为只是语句MainWindow->new就需要很多步骤。

(旧信息):Gurusamy Sarathy作了一个PERL5DB文件叫Tkperldb(尽管这个名字是对pTk而不是Tk/perl的)。要使用这个调试器,用户必须安装一个早期版本的调试器,然后打一个补丁来调用它。老版本的调试器安装包可以从下面的地址得到:

ftp://ftp.perl.com/pub/perl/ext/TK/

并且Gurusamy Sarathy发现要调用这个调试器的补丁的获得方法如下:

你需要一个张贴出来的5.001m版本的perl,因为他支持调试关闭(?)。

或者你可以简单的在5.001m上用http://www-personal.umich.edu/~gsar/。(5.002beta已经包含上面的补丁的修复)。

请注意,你可以在你的脚本中使用如下面的一行代码来调用perl调试器:

$ENV{'PERL5DB'} = 'BEGIN { require Tkperldb }';

需要更多的帮助请参阅perldebug的手册页:perldoc perldebug。

记住,你毕竟是在调试一个perl程序。因此你完全可以使用perl的命令行调试方式,也就是在shell中执行如下命令:

perl –de 0

但是,你必须输入脚本的所有行,包括use Tk;。当你使用perl –dwe 0时,请注意这个调试器是支持如emacs的行编辑的。另外,预先说明一下,一旦你输入了MainLoop;语句,perl就不会再从标准输入STDIN读取内容了。

Ilya Zakharevich指出,最近版本的perldb将允许同时从X和STDIN读取输入。他还指出:

注意,你还可以使用:

sub myLoop {

if (defined &DB::DB) {

while (1) { # MainWindow->Count

Tk::DoOneEvent(0);

}

} else {

MainLoop;

}

}

(并且,我希望Nick会在MainLoop中也提供相应的功能。)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
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- 王朝网络 版权所有