perlfaq1.pod

来自「MSYS在windows下模拟了一个类unix的终端」· POD 代码 · 共 329 行 · 第 1/2 页

POD
329
字号
For others, it serves as a convenient, high-level replacement for most ofwhat they'd program in low-level languages like C or C++.  It's ultimatelyup to you (and possibly your management) which tasks you'll use Perlfor and which you won't.If you have a library that provides an API, you can make any componentof it available as just another Perl function or variable using a Perlextension written in C or C++ and dynamically linked into your mainperl interpreter.  You can also go the other direction, and write yourmain program in C or C++, and then link in some Perl code on the fly,to create a powerful application.  See L<perlembed>.That said, there will always be small, focused, special-purposelanguages dedicated to a specific problem domain that are simply moreconvenient for certain kinds of problems.  Perl tries to be all thingsto all people, but nothing special to anyone.  Examples of specializedlanguages that come to mind include prolog and matlab.=head2 When shouldn't I program in Perl?When your manager forbids it--but do consider replacing them :-).Actually, one good reason is when you already have an existingapplication written in another language that's all done (and donewell), or you have an application language specifically designed for acertain task (e.g. prolog, make).For various reasons, Perl is probably not well-suited for real-timeembedded systems, low-level operating systems development work likedevice drivers or context-switching code, complex multi-threadedshared-memory applications, or extremely large applications.  You'llnotice that perl is not itself written in Perl.The new, native-code compiler for Perl may eventually reduce thelimitations given in the previous statement to some degree, but understandthat Perl remains fundamentally a dynamically typed language, nota statically typed one.  You certainly won't be chastised if you don'ttrust nuclear-plant or brain-surgery monitoring code to it.  And Larrywill sleep easier, too--Wall Street programs not withstanding. :-)=head2 What's the difference between "perl" and "Perl"?One bit.  Oh, you weren't talking ASCII? :-) Larry now uses "Perl" tosignify the language proper and "perl" the implementation of it,i.e. the current interpreter.  Hence Tom's quip that "Nothing but perlcan parse Perl."  You may or may not choose to follow this usage.  Forexample, parallelism means "awk and perl" and "Python and Perl" lookOK, while "awk and Perl" and "Python and perl" do not.  But neverwrite "PERL", because perl isn't really an acronym, apocryphalfolklore and post-facto expansions notwithstanding.=head2 Is it a Perl program or a Perl script?Larry doesn't really care.  He says (half in jest) that "a script iswhat you give the actors.  A program is what you give the audience."Originally, a script was a canned sequence of normally interactivecommands--that is, a chat script.  Something like a UUCP or PPP chatscript or an expect script fits the bill nicely, as do configurationscripts run by a program at its start up, such F<.cshrc> or F<.ircrc>,for example.  Chat scripts were just drivers for existing programs,not stand-alone programs in their own right.A computer scientist will correctly explain that all programs areinterpreted and that the only question is at what level.  But if youask this question of someone who isn't a computer scientist, they mighttell you that a I<program> has been compiled to physical machine codeonce and can then be run multiple times, whereas a I<script> must betranslated by a program each time it's used.Perl programs are (usually) neither strictly compiled nor strictlyinterpreted.  They can be compiled to a byte-code form (something of aPerl virtual machine) or to completely different languages, like C orassembly language.  You can't tell just by looking at it whether thesource is destined for a pure interpreter, a parse-tree interpreter,a byte-code interpreter, or a native-code compiler, so it's hard to givea definitive answer here.Now that "script" and "scripting" are terms that have been seized byunscrupulous or unknowing marketeers for their own nefarious purposes,they have begun to take on strange and often pejorative meanings,like "non serious" or "not real programming".  Consequently, some Perlprogrammers prefer to avoid them altogether.=head2 What is a JAPH?These are the "just another perl hacker" signatures that some peoplesign their postings with.  Randal Schwartz made these famous.  About100 of the earlier ones are available fromhttp://www.perl.com/CPAN/misc/japh .=head2 Where can I get a list of Larry Wall witticisms?Over a hundred quips by Larry, from postings of his or source code,can be found at http://www.perl.com/CPAN/misc/lwall-quotes.txt.gz .Newer examples can be found by perusing Larry's postings:    http://x1.dejanews.com/dnquery.xp?QRY=*&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=terse&showsort=date&maxhits=100&subjects=&groups=&authors=larry@*wall.org&fromdate=&todate==head2 How can I convince my sysadmin/supervisor/employees to use version 5/5.005/Perl instead of some other language?If your manager or employees are wary of unsupported software, orsoftware which doesn't officially ship with your operating system, youmight try to appeal to their self-interest.  If programmers can bemore productive using and utilizing Perl constructs, functionality,simplicity, and power, then the typical manager/supervisor/employeemay be persuaded.  Regarding using Perl in general, it's alsosometimes helpful to point out that delivery times may be reducedusing Perl compared to other languages.If you have a project which has a bottleneck, especially in terms oftranslation or testing, Perl almost certainly will provide a viable,quick solution.  In conjunction with any persuasion effort, youshould not fail to point out that Perl is used, quite extensively, andwith extremely reliable and valuable results, at many large computersoftware and hardware companies throughout the world.  In fact,many Unix vendors now ship Perl by default.  Support is usuallyjust a news-posting away, if you can't find the answer in theI<comprehensive> documentation, including this FAQ.See http://www.perl.org/advocacy/ for more information.If you face reluctance to upgrading from an older version of perl,then point out that version 4 is utterly unmaintained and unsupportedby the Perl Development Team.  Another big sell for Perl5 is the largenumber of modules and extensions which greatly reduce development timefor any given task.  Also mention that the difference between version4 and version 5 of Perl is like the difference between awk and C++.(Well, OK, maybe it's not quite that distinct, but you get the idea.)If you want support and a reasonable guarantee that what you'redeveloping will continue to work in the future, then you have to runthe supported version.  As of April 2001 that probably meansrunning either of the releases 5.6.1 (released in April 2001) or5.005_03 (released in March 1999), although 5.004_05 isn't that badif you B<absolutely> need such an old version (released in April 1999)for stability reasons.  Anything older than 5.004_05 shouldn't be used.Of particular note is the massive bug hunt for buffer overflowproblems that went into the 5.004 release.  All releases prior tothat, including perl4, are considered insecure and should be upgradedas soon as possible.In August 2000 in all Linux distributions a new security problem wasfound in the optional 'suidperl' (not built or installed by default)in all the Perl branches 5.6, 5.005, and 5.004, seehttp://www.cpan.org/src/5.0/sperl-2000-08-05/=head1 AUTHOR AND COPYRIGHTCopyright (c) 1997, 1998, 1999, 2000, 2001 Tom Christiansen and NathanTorkington.  All rights reserved.When included as an integrated part of the Standard Distributionof Perl or of its documentation (printed or otherwise), this works iscovered under Perl's Artistic Licence.  For separate distributions ofall or part of this FAQ outside of that, see L<perlfaq>.Irrespective of its distribution, all code examples here are in the publicdomain.  You are permitted and encouraged to use this code and anyderivatives thereof in your own programs for fun or for profit as yousee fit.  A simple comment in the code giving credit to the FAQ wouldbe courteous but is not required.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?