📄 perlfaq3.1
字号:
\&\f(CW\*(C`ptkdb\*(C'\fR. It's on \s-1CPAN\s0 and available for free..PPIf you need something much more sophisticated and controllable, LeonBrocard's Devel::ebug (which you can call with the \-D switch as \-Debug)gives you the programmatic hooks into everything you need to write yourown (without too much pain and suffering)..PPYou can also use a commercial debugger such as Affrus (Mac \s-1OS\s0 X), Komodofrom Activestate (Windows and Mac \s-1OS\s0 X), or \s-1EPIC\s0 (most platforms)..Sh "How do I profile my Perl programs?".IX Subsection "How do I profile my Perl programs?"You should get the Devel::DProf module from the standard distribution(or separately on \s-1CPAN\s0) and also use Benchmark.pm from the standarddistribution. The Benchmark module lets you time specific portions ofyour code, while Devel::DProf gives detailed breakdowns of where yourcode spends its time..PPHere's a sample use of Benchmark:.PP.Vb 1\& use Benchmark;\&\& @junk = \`cat /etc/motd\`;\& $count = 10_000;\&\& timethese($count, {\& \*(Aqmap\*(Aq => sub { my @a = @junk;\& map { s/a/b/ } @a;\& return @a },\& \*(Aqfor\*(Aq => sub { my @a = @junk;\& for (@a) { s/a/b/ };\& return @a },\& });.Ve.PPThis is what it prints (on one machine\*(--your results will be dependenton your hardware, operating system, and the load on your machine):.PP.Vb 3\& Benchmark: timing 10000 iterations of for, map...\& for: 4 secs ( 3.97 usr 0.01 sys = 3.98 cpu)\& map: 6 secs ( 4.97 usr 0.00 sys = 4.97 cpu).Ve.PPBe aware that a good benchmark is very hard to write. It only tests thedata you give it and proves little about the differing complexitiesof contrasting algorithms..Sh "How do I cross-reference my Perl programs?".IX Subsection "How do I cross-reference my Perl programs?"The B::Xref module can be used to generate cross-reference reportsfor Perl programs..PP.Vb 1\& perl \-MO=Xref[,OPTIONS] scriptname.plx.Ve.Sh "Is there a pretty-printer (formatter) for Perl?".IX Subsection "Is there a pretty-printer (formatter) for Perl?"Perltidy is a Perl script which indents and reformats Perl scriptsto make them easier to read by trying to follow the rules of theperlstyle. If you write Perl scripts, or spend much time readingthem, you will probably find it useful. It is available athttp://perltidy.sourceforge.net.PPOf course, if you simply follow the guidelines in perlstyle,you shouldn't need to reformat. The habit of formatting your codeas you write it will help prevent bugs. Your editor can and shouldhelp you with this. The perl-mode or newer cperl-mode for emacscan provide remarkable amounts of help with most (but not all)code, and even less programmable editors can provide significantassistance. Tom Christiansen and many other \s-1VI\s0 users swear bythe following settings in vi and its clones:.PP.Vb 2\& set ai sw=4\& map! ^O {^M}^[O^T.Ve.PPPut that in your \fI.exrc\fR file (replacing the caret characterswith control characters) and away you go. In insert mode, ^T isfor indenting, ^D is for undenting, and ^O is for blockdenting\*(--asit were. A more complete example, with comments, can be found athttp://www.cpan.org/authors/id/TOMC/scripts/toms.exrc.gz.PPThe a2ps http://www\-inf.enst.fr/%7Edemaille/a2ps/black+white.ps.gz doeslots of things related to generating nicely printed output ofdocuments..Sh "Is there a ctags for Perl?".IX Subsection "Is there a ctags for Perl?"(contributed by brian d foy).PPCtags uses an index to quickly find things in source code, and manypopular editors support ctags for several different languages,including Perl..PPExuberent ctags supports Perl: http://ctags.sourceforge.net/.PPYou might also try pltags: http://www.mscha.com/pltags.zip.Sh "Is there an \s-1IDE\s0 or Windows Perl Editor?".IX Subsection "Is there an IDE or Windows Perl Editor?"Perl programs are just plain text, so any editor will do..PPIf you're on Unix, you already have an IDE\*(--Unix itself. The \s-1UNIX\s0philosophy is the philosophy of several small tools that each do onething and do it well. It's like a carpenter's toolbox..PPIf you want an \s-1IDE\s0, check the following (in alphabetical order, notorder of preference):.IP "Eclipse" 4.IX Item "Eclipse"http://e\-p\-i\-c.sf.net/.SpThe Eclipse Perl Integration Project integrates Perlediting/debugging with Eclipse..IP "Enginsite" 4.IX Item "Enginsite"http://www.enginsite.com/.SpPerl Editor by EngInSite is a complete integrated developmentenvironment (\s-1IDE\s0) for creating, testing, and debugging Perl scripts;the tool runs on Windows 9x/NT/2000/XP or later..IP "Komodo" 4.IX Item "Komodo"http://www.ActiveState.com/Products/Komodo/.SpActiveState's cross-platform (as of October 2004, that's Windows, Linux,and Solaris), multi-language \s-1IDE\s0 has Perl support, including a regular expressiondebugger and remote debugging..IP "Open Perl \s-1IDE\s0" 4.IX Item "Open Perl IDE"http://open\-perl\-ide.sourceforge.net/.SpOpen Perl \s-1IDE\s0 is an integrated development environment for writingand debugging Perl scripts with ActiveState's ActivePerl distributionunder Windows 95/98/NT/2000..IP "OptiPerl" 4.IX Item "OptiPerl"http://www.optiperl.com/.SpOptiPerl is a Windows \s-1IDE\s0 with simulated \s-1CGI\s0 environment, includingdebugger and syntax highlighting editor..IP "PerlBuilder" 4.IX Item "PerlBuilder"http://www.solutionsoft.com/perl.htm.SpPerlBuidler is an integrated development environment for Windows thatsupports Perl development..IP "visiPerl+" 4.IX Item "visiPerl+"http://helpconsulting.net/visiperl/.SpFrom Help Consulting, for Windows..IP "Visual Perl" 4.IX Item "Visual Perl"http://www.activestate.com/Products/Visual_Perl/.SpVisual Perl is a Visual Studio.NET plug-in from ActiveState..IP "Zeus" 4.IX Item "Zeus"http://www.zeusedit.com/lookmain.html.SpZeus for Window is another Win32 multi-language editor/IDEthat comes with support for Perl:.PPFor editors: if you're on Unix you probably have vi or a vi clonealready, and possibly an emacs too, so you may not need to downloadanything. In any emacs the cperl-mode (M\-x cperl-mode) gives youperhaps the best available Perl editing mode in any editor..PPIf you are using Windows, you can use any editor that lets you workwith plain text, such as NotePad or WordPad. Word processors, such asMicrosoft Word or WordPerfect, typically do not work since they insertall sorts of behind-the-scenes information, although some allow you tosave files as \*(L"Text Only\*(R". You can also download text editors designedspecifically for programming, such as Textpad (http://www.textpad.com/ ) and UltraEdit ( http://www.ultraedit.com/ ),among others..PPIf you are using MacOS, the same concerns apply. MacPerl (for Classicenvironments) comes with a simple editor. Popular external editors areBBEdit ( http://www.bbedit.com/ ) or Alpha (http://www.his.com/~jguyer/Alpha/Alpha8.html ). MacOS X users can useUnix editors as well..IP "\s-1GNU\s0 Emacs" 4.IX Item "GNU Emacs"http://www.gnu.org/software/emacs/windows/ntemacs.html.IP "MicroEMACS" 4.IX Item "MicroEMACS"http://www.microemacs.de/.IP "XEmacs" 4.IX Item "XEmacs"http://www.xemacs.org/Download/index.html.IP "Jed" 4.IX Item "Jed"http://space.mit.edu/~davis/jed/.PPor a vi clone such as.IP "Elvis" 4.IX Item "Elvis"ftp://ftp.cs.pdx.edu/pub/elvis/ http://www.fh\-wedel.de/elvis/.IP "Vile" 4.IX Item "Vile"http://dickey.his.com/vile/vile.html.IP "Vim" 4.IX Item "Vim"http://www.vim.org/.PPFor vi lovers in general, Windows or elsewhere:.PP.Vb 1\& http://www.thomer.com/thomer/vi/vi.html.Ve.PPnvi ( http://www.bostic.com/vi/ , available from \s-1CPAN\s0 in src/misc/) isyet another vi clone, unfortunately not available for Windows, but in\&\s-1UNIX\s0 platforms you might be interested in trying it out, firstly becausestrictly speaking it is not a vi clone, it is the real vi, or the newincarnation of it, and secondly because you can embed Perl inside itto use Perl as the scripting language. nvi is not alone in this,though: at least also vim and vile offer an embedded Perl..PPThe following are Win32 multilanguage editor/IDESs that support Perl:.IP "Codewright" 4.IX Item "Codewright"http://www.borland.com/codewright/.IP "MultiEdit" 4.IX Item "MultiEdit"http://www.MultiEdit.com/.IP "SlickEdit" 4.IX Item "SlickEdit"http://www.slickedit.com/.PPThere is also a toyedit Text widget based editor written in Perlthat is distributed with the Tk module on \s-1CPAN\s0. The ptkdb( http://ptkdb.sourceforge.net/ ) is a Perl/tk based debugger thatacts as a development environment of sorts. Perl Composer( http://perlcomposer.sourceforge.net/ ) is an \s-1IDE\s0 for Perl/Tk\&\s-1GUI\s0 creation..PPIn addition to an editor/IDE you might be interested in a morepowerful shell environment for Win32. Your options include.IP "Bash" 4.IX Item "Bash"from the Cygwin package ( http://sources.redhat.com/cygwin/ ).IP "Ksh" 4.IX Item "Ksh"from the \s-1MKS\s0 Toolkit ( http://www.mks.com/ ), or the Bourne shell ofthe U/WIN environment ( http://www.research.att.com/sw/tools/uwin/ ).IP "Tcsh" 4.IX Item "Tcsh"ftp://ftp.astron.com/pub/tcsh/ , see alsohttp://www.primate.wisc.edu/software/csh\-tcsh\-book/.IP "Zsh" 4.IX Item "Zsh"http://www.zsh.org/.PP\&\s-1MKS\s0 and U/WIN are commercial (U/WIN is free for educational andresearch purposes), Cygwin is covered by the \s-1GNU\s0 Public License (butthat shouldn't matter for Perl use). The Cygwin, \s-1MKS\s0, and U/WIN allcontain (in addition to the shells) a comprehensive set of standard\&\s-1UNIX\s0 toolkit utilities..PPIf you're transferring text files between Unix and Windows using \s-1FTP\s0be sure to transfer them in \s-1ASCII\s0 mode so the ends of lines areappropriately converted..PPOn Mac \s-1OS\s0 the MacPerl Application comes with a simple 32k text editorthat behaves like a rudimentary \s-1IDE\s0. In contrast to the MacPerl Applicationthe \s-1MPW\s0 Perl tool can make use of the \s-1MPW\s0 Shell itself as an editor (withno 32k limit)..IP "Affrus" 4.IX Item "Affrus"is a full Perl development environment with full debugger support( http://www.latenightsw.com )..IP "Alpha" 4.IX Item "Alpha"is an editor, written and extensible in Tcl, that nonetheless hasbuilt in support for several popular markup and programming languagesincluding Perl and \s-1HTML\s0 ( http://www.his.com/~jguyer/Alpha/Alpha8.html )..IP "BBEdit and BBEdit Lite" 4.IX Item "BBEdit and BBEdit Lite"are text editors for Mac \s-1OS\s0 that have a Perl sensitivity mode( http://web.barebones.com/ )..PPPepper and Pe are programming language sensitive text editors for Mac\&\s-1OS\s0 X and BeOS respectively ( http://www.hekkelman.com/ )..Sh "Where can I get Perl macros for vi?".IX Subsection "Where can I get Perl macros for vi?"For a complete version of Tom Christiansen's vi configuration file,see http://www.cpan.org/authors/Tom_Christiansen/scripts/toms.exrc.gz ,the standard benchmark file for vi emulators. The file runs best with nvi,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -