Debugging Perl
?How to Debug Perl Library and Scripts? ? 1.?Changing @INC - where Perl loads its modules (http://www.wellho.net/mouth/588_Changing-INC-where-Perl-loads-its-modules.html)? The @INC?array is a list of directories?Perl?searches when attempting to load modules.? Where does Perl load modules from in its?use?and?require?statements? It loads them from directorys in a special list called?@INC,from files with a .pm extension in those directorys.?
perl -I /Users/grahamellis/jan06 i2?
BEGIN {? Rather curiously,??calls are run at compile time not at run time ... but then so are BEGIN blocks ... so you put your manipulation of @INC into one of those to get it to happen early enough.?
export PERL5LIB=/Users/grahamellis/jan06? and you can use a colon separated list for that if you want to pre-pend more than one directory.
2. Debugging Perl?http://ralphie.perlmonk.org/mosix/debug.htmlTo check the syntax of your scripts,type "perl -c?scriptname.pl " . It is also worthwhile to add the -w switch ("perl -cw ..."),to turn on warning mode. If you were wise enough to "use strict" in the body of the code,the syntax check will also specify inappropriate scalar scoping,which goes a little beyond the normal syntactical problems that are identified. Once your script will pass through the syntax check with a "syntax ok" message,you will have a legal perl script from the standpoint that all of the statements are legal perl statements. That doesn't mean that the manner in which any given statement is expressed will return the result that you are looking for,that the functions that are used in the code are the right ones for the job,or that the overall structure of the script does anything like what you think it supposed to do. It just means that all of the perl i's are dotted and t's are crossed. (On the other hand,this is not such a minor thing,either.) 3. perldebug (http://perldoc.perl.org/perldebug.html) Calling the debugger There are several ways to call the debugger:
On the given program identified by?program_name?.
Interactively supply an arbitrary?expression?using?-e?.
Debug a given program via the?Devel::Ptkdb?GUI.
Debug a given program using threads (experimental). 4. Summary of Subprocess Operations
? Above table is from the book Learning Perl. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |