perlfaq3.html
来自「perl教程」· HTML 代码 · 共 1,053 行 · 第 1/5 页
HTML
1,053 行
</dl>
<p>or a vi clone such as</p>
<dl>
<dt><strong><a name="item_elvis">Elvis</a></strong>
<dd>
<p><a href="ftp://ftp.cs.pdx.edu/pub/elvis/">ftp://ftp.cs.pdx.edu/pub/elvis/</a> <a href="http://www.fh-wedel.de/elvis/">http://www.fh-wedel.de/elvis/</a></p>
</dd>
</li>
<dt><strong><a name="item_vile">Vile</a></strong>
<dd>
<p><a href="http://dickey.his.com/vile/vile.html">http://dickey.his.com/vile/vile.html</a></p>
</dd>
</li>
<dt><strong><a name="item_vim">Vim</a></strong>
<dd>
<p><a href="http://www.vim.org/">http://www.vim.org/</a></p>
</dd>
</li>
</dl>
<p>For vi lovers in general, Windows or elsewhere:</p>
<pre>
<a href="http://www.thomer.com/thomer/vi/vi.html">http://www.thomer.com/thomer/vi/vi.html</a></pre>
<p>nvi ( <a href="http://www.bostic.com/vi/">http://www.bostic.com/vi/</a> , available from CPAN in src/misc/) is
yet another vi clone, unfortunately not available for Windows, but in
UNIX platforms you might be interested in trying it out, firstly because
strictly speaking it is not a vi clone, it is the real vi, or the new
incarnation of it, and secondly because you can embed Perl inside it
to use Perl as the scripting language. nvi is not alone in this,
though: at least also vim and vile offer an embedded Perl.</p>
<p>The following are Win32 multilanguage editor/IDESs that support Perl:</p>
<dl>
<dt><strong><a name="item_codewright">Codewright</a></strong>
<dd>
<p><a href="http://www.borland.com/codewright/">http://www.borland.com/codewright/</a></p>
</dd>
</li>
<dt><strong><a name="item_multiedit">MultiEdit</a></strong>
<dd>
<p><a href="http://www.MultiEdit.com/">http://www.MultiEdit.com/</a></p>
</dd>
</li>
<dt><strong><a name="item_slickedit">SlickEdit</a></strong>
<dd>
<p><a href="http://www.slickedit.com/">http://www.slickedit.com/</a></p>
</dd>
</li>
</dl>
<p>There is also a toyedit Text widget based editor written in Perl
that is distributed with the Tk module on CPAN. The ptkdb
( <a href="http://world.std.com/~aep/ptkdb/">http://world.std.com/~aep/ptkdb/</a> ) is a Perl/tk based debugger that
acts as a development environment of sorts. Perl Composer
( <a href="http://perlcomposer.sourceforge.net/">http://perlcomposer.sourceforge.net/</a> ) is an IDE for Perl/Tk
GUI creation.</p>
<p>In addition to an editor/IDE you might be interested in a more
powerful shell environment for Win32. Your options include</p>
<dl>
<dt><strong><a name="item_bash">Bash</a></strong>
<dd>
<p>from the Cygwin package ( <a href="http://sources.redhat.com/cygwin/">http://sources.redhat.com/cygwin/</a> )</p>
</dd>
</li>
<dt><strong><a name="item_ksh">Ksh</a></strong>
<dd>
<p>from the MKS Toolkit ( <a href="http://www.mks.com/">http://www.mks.com/</a> ), or the Bourne shell of
the U/WIN environment ( <a href="http://www.research.att.com/sw/tools/uwin/">http://www.research.att.com/sw/tools/uwin/</a> )</p>
</dd>
</li>
<dt><strong><a name="item_tcsh">Tcsh</a></strong>
<dd>
<p><a href="ftp://ftp.astron.com/pub/tcsh/">ftp://ftp.astron.com/pub/tcsh/</a> , see also
<a href="http://www.primate.wisc.edu/software/csh-tcsh-book/">http://www.primate.wisc.edu/software/csh-tcsh-book/</a></p>
</dd>
</li>
<dt><strong><a name="item_zsh">Zsh</a></strong>
<dd>
<p><a href="ftp://ftp.blarg.net/users/amol/zsh/">ftp://ftp.blarg.net/users/amol/zsh/</a> , see also <a href="http://www.zsh.org/">http://www.zsh.org/</a></p>
</dd>
</li>
</dl>
<p>MKS and U/WIN are commercial (U/WIN is free for educational and
research purposes), Cygwin is covered by the GNU Public License (but
that shouldn't matter for Perl use). The Cygwin, MKS, and U/WIN all
contain (in addition to the shells) a comprehensive set of standard
UNIX toolkit utilities.</p>
<p>If you're transferring text files between Unix and Windows using FTP
be sure to transfer them in ASCII mode so the ends of lines are
appropriately converted.</p>
<p>On Mac OS the MacPerl Application comes with a simple 32k text editor
that behaves like a rudimentary IDE. In contrast to the MacPerl Application
the MPW Perl tool can make use of the MPW Shell itself as an editor (with
no 32k limit).</p>
<dl>
<dt><strong><a name="item_affrus">Affrus</a></strong>
<dd>
<p>is a full Perl development environment with full debugger support
( <a href="http://www.latenightsw.com">http://www.latenightsw.com</a> ).</p>
</dd>
</li>
<dt><strong><a name="item_alpha">Alpha</a></strong>
<dd>
<p>is an editor, written and extensible in Tcl, that nonetheless has
built in support for several popular markup and programming languages
including Perl and HTML ( <a href="http://www.his.com/~jguyer/Alpha/Alpha8.html">http://www.his.com/~jguyer/Alpha/Alpha8.html</a> ).</p>
</dd>
</li>
<dt><strong><a name="item_bbedit_and_bbedit_lite">BBEdit and BBEdit Lite</a></strong>
<dd>
<p>are text editors for Mac OS that have a Perl sensitivity mode
( <a href="http://web.barebones.com/">http://web.barebones.com/</a> ).</p>
</dd>
</li>
</dl>
<p>Pepper and Pe are programming language sensitive text editors for Mac
OS X and BeOS respectively ( <a href="http://www.hekkelman.com/">http://www.hekkelman.com/</a> ).</p>
<p>
</p>
<h2><a name="where_can_i_get_perl_macros_for_vi">Where can I get Perl macros for vi?</a></h2>
<p>For a complete version of Tom Christiansen's vi configuration file,
see <a href="http://www.cpan.org/authors/Tom_Christiansen/scripts/toms.exrc.gz">http://www.cpan.org/authors/Tom_Christiansen/scripts/toms.exrc.gz</a> ,
the standard benchmark file for vi emulators. The file runs best with nvi,
the current version of vi out of Berkeley, which incidentally can be built
with an embedded Perl interpreter--see <a href="http://www.cpan.org/src/misc/">http://www.cpan.org/src/misc/</a> .</p>
<p>
</p>
<h2><a name="where_can_i_get_perlmode_for_emacs">Where can I get perl-mode for emacs?</a></h2>
<p>Since Emacs version 19 patchlevel 22 or so, there have been both a
perl-mode.el and support for the Perl debugger built in. These should
come with the standard Emacs 19 distribution.</p>
<p>In the Perl source directory, you'll find a directory called "emacs",
which contains a cperl-mode that color-codes keywords, provides
context-sensitive help, and other nifty things.</p>
<p>Note that the perl-mode of emacs will have fits with <code>"main'foo"</code>
(single quote), and mess up the indentation and highlighting. You
are probably using <code>"main::foo"</code> in new Perl code anyway, so this
shouldn't be an issue.</p>
<p>
</p>
<h2><a name="how_can_i_use_curses_with_perl">How can I use curses with Perl?</a></h2>
<p>The Curses module from CPAN provides a dynamically loadable object
module interface to a curses library. A small demo can be found at the
directory <a href="http://www.cpan.org/authors/Tom_Christiansen/scripts/rep.gz">http://www.cpan.org/authors/Tom_Christiansen/scripts/rep.gz</a> ;
this program repeats a command and updates the screen as needed, rendering
<strong>rep ps axu</strong> similar to <strong>top</strong>.</p>
<p>
</p>
<h2><a name="how_can_i_use_x_or_tk_with_perl">How can I use X or Tk with Perl?</a></h2>
<p>Tk is a completely Perl-based, object-oriented interface to the Tk toolkit
that doesn't force you to use Tcl just to get at Tk. Sx is an interface
to the Athena Widget set. Both are available from CPAN. See the
directory <a href="http://www.cpan.org/modules/by-category/08_User_Interfaces/">http://www.cpan.org/modules/by-category/08_User_Interfaces/</a></p>
<p>Invaluable for Perl/Tk programming are the Perl/Tk FAQ at
<a href="http://phaseit.net/claird/comp.lang.perl.tk/ptkFAQ.html">http://phaseit.net/claird/comp.lang.perl.tk/ptkFAQ.html</a> , the Perl/Tk Reference
Guide available at
<a href="http://www.cpan.org/authors/Stephen_O_Lidie/">http://www.cpan.org/authors/Stephen_O_Lidie/</a> , and the
online manpages at
<a href="http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html">http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html</a> .</p>
<p>
</p>
<h2><a name="how_can_i_make_my_perl_program_run_faster">How can I make my Perl program run faster?</a></h2>
<p>The best way to do this is to come up with a better algorithm. This
can often make a dramatic difference. Jon Bentley's book
<em>Programming Pearls</em> (that's not a misspelling!) has some good tips
on optimization, too. Advice on benchmarking boils down to: benchmark
and profile to make sure you're optimizing the right part, look for
better algorithms instead of microtuning your code, and when all else
fails consider just buying faster hardware. You will probably want to
read the answer to the earlier question "How do I profile my Perl
programs?" if you haven't done so already.</p>
<p>A different approach is to autoload seldom-used Perl code. See the
AutoSplit and AutoLoader modules in the standard distribution for
that. Or you could locate the bottleneck and think about writing just
that part in C, the way we used to take bottlenecks in C code and
write them in assembler. Similar to rewriting in C, modules that have
critical sections can be written in C (for instance, the PDL module
from CPAN).</p>
<p>If you're currently linking your perl executable to a shared
<em>libc.so</em>, you can often gain a 10-25% performance benefit by
rebuilding it to link with a static libc.a instead. This will make a
bigger perl executable, but your Perl programs (and programmers) may
thank you for it. See the <em>INSTALL</em> file in the source distribution
for more information.</p>
<p>The undump program was an ancient attempt to speed up Perl program by
storing the already-compiled form to disk. This is no longer a viable
option, as it only worked on a few architectures, and wasn't a good
solution anyway.</p>
<p>
</p>
<h2><a name="how_can_i_make_my_perl_program_take_less_memory">How can I make my Perl program take less memory?</a></h2>
<p>When it comes to time-space tradeoffs, Perl nearly always prefers to
throw memory at a problem. Scalars in Perl use more memory than
strings in C, arrays take more than that, and hashes use even more. While
there's still a lot to be done, recent releases have been addressing
these issues. For example, as of 5.004, duplicate hash keys are
shared amongst all hashes using them, so require no reallocation.</p>
<p>In some cases, using <a href="../../lib/Pod/perlvar.html#item_substr"><code>substr()</code></a> or <a href="../../lib/Pod/perlfunc.html#item_vec"><code>vec()</code></a> to simulate arrays can be
highly beneficial. For example, an array of a thousand booleans will
take at least 20,000 bytes of space, but it can be turned into one
125-byte bit vector--a considerable memory savings. The standard
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?