📄 perlfaq1.1
字号:
.PPSee perlhist for a history of Perl revisions..Sh "What was Ponie?".IX Subsection "What was Ponie?"(contributed by brian d foy).PPPonie stands for \*(L"Perl On the New Internal Engine\*(R", started by ArthurBergman from Fotango in 2003, and subsequently run as a project of ThePerl Foundation. It was abandoned in 2006( http://www.nntp.perl.org/group/perl.ponie.dev/487 )..PPInstead of using the current Perl internals, Ponie aimed to create anew one that would provide a translation path from Perl 5 to Perl 6(or anything else that targets Parrot, actually). You would have beenable to just keep using Perl 5 with Parrot, the virtual machine whichwill compile and run Perl 6 bytecode..Sh "What is Perl 6?".IX Subsection "What is Perl 6?"At The Second O'Reilly Open Source Software Convention, Larry Wallannounced Perl 6 development would begin in earnest. Perl 6 was an oftused term for Chip Salzenberg's project to rewrite Perl in \*(C+ namedTopaz. However, Topaz provided valuable insights to the next versionof Perl and its implementation, but was ultimately abandoned..PPIf you want to learn more about Perl 6, or have a desire to help inthe crusade to make Perl a better place then peruse the Perl 6 developerspage at http://dev.perl.org/perl6/ and get involved..PPPerl 6 is not scheduled for release yet, and Perl 5 will still be supportedfor quite awhile after its release. Do not wait for Perl 6 to do whateveryou need to do..PP\&\*(L"We're really serious about reinventing everything that needs reinventing.\*(R"\&\-\-Larry Wall.Sh "How stable is Perl?".IX Subsection "How stable is Perl?"Production releases, which incorporate bug fixes and new functionality,are widely tested before release. Since the 5.000 release, we haveaveraged only about one production release per year..PPLarry and the Perl development team occasionally make changes to theinternal core of the language, but all possible efforts are made towardbackward compatibility. While not quite all Perl 4 scripts run flawlesslyunder Perl 5, an update to perl should nearly never invalidate a programwritten for an earlier version of perl (barring accidental bug fixesand the rare new keyword)..Sh "Is Perl difficult to learn?".IX Subsection "Is Perl difficult to learn?"No, Perl is easy to start learning\*(--and easy to keep learning. It lookslike most programming languages you're likely to have experiencewith, so if you've ever written a C program, an awk script, a shellscript, or even a \s-1BASIC\s0 program, you're already partway there..PPMost tasks only require a small subset of the Perl language. One ofthe guiding mottos for Perl development is \*(L"there's more than one wayto do it\*(R" (\s-1TMTOWTDI\s0, sometimes pronounced \*(L"tim toady\*(R"). Perl'slearning curve is therefore shallow (easy to learn) and long (there'sa whole lot you can do if you really want)..PPFinally, because Perl is frequently (but not always, and certainly not bydefinition) an interpreted language, you can write your programs and testthem without an intermediate compilation step, allowing you to experimentand test/debug quickly and easily. This ease of experimentation flattensthe learning curve even more..PPThings that make Perl easier to learn: Unix experience, almost any kindof programming experience, an understanding of regular expressions, andthe ability to understand other people's code. If there's something youneed to do, then it's probably already been done, and a working example isusually available for free. Don't forget Perl modules, either.They're discussed in Part 3 of this \s-1FAQ\s0, along with \s-1CPAN\s0, which isdiscussed in Part 2..Sh "How does Perl compare with other languages like Java, Python, \s-1REXX\s0, Scheme, or Tcl?".IX Subsection "How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?"Favorably in some areas, unfavorably in others. Precisely which areasare good and bad is often a personal choice, so asking this questionon Usenet runs a strong risk of starting an unproductive Holy War..PPProbably the best thing to do is try to write equivalent code to do aset of tasks. These languages have their own newsgroups in which youcan learn about (but hopefully not argue about) them..PPSome comparison documents can be found at http://www.perl.com/doc/FMTEYEWTK/versus/if you really can't stop yourself..Sh "Can I do [task] in Perl?".IX Subsection "Can I do [task] in Perl?"Perl is flexible and extensible enough for you to use on virtually anytask, from one-line file-processing tasks to large, elaborate systems.For many people, Perl serves as a great replacement for shell scripting.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..PPIf you have a library that provides an \s-1API\s0, 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 perlembed..PPThat 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..Sh "When shouldn't I program in Perl?".IX Subsection "When shouldn't I program in Perl?"When your manager forbids it\*(--but do consider replacing them :\-)..PPActually, 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)..PPFor 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..PPPerl 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. :\-).ie n .Sh "What's the difference between ""perl"" and ""Perl""?".el .Sh "What's the difference between ``perl'' and ``Perl''?".IX Subsection "What's the difference between perl and Perl?"One bit. Oh, you weren't talking \s-1ASCII\s0? :\-) Larry now uses \*(L"Perl\*(R" tosignify the language proper and \*(L"perl\*(R" the implementation of it, i.e.the current interpreter. Hence Tom's quip that \*(L"Nothing but perl canparse Perl.\*(R".PPBefore the first edition of \fIProgramming perl\fR, people commonlyreferred to the language as \*(L"perl\*(R", and its name appeared that way inthe title because it referred to the interpreter. In the book, RandalSchwartz capitalised the language's name to make it stand out betterwhen typeset. This convention was adopted by the community, and thesecond edition became \fIProgramming Perl\fR, using the capitalizedversion of the name to refer to the language..PPYou may or may not choose to follow this usage. For example,parallelism means \*(L"awk and perl\*(R" and \*(L"Python and Perl\*(R" look good, while\&\*(L"awk and Perl\*(R" and \*(L"Python and perl\*(R" do not. But never write \*(L"\s-1PERL\s0\*(R",because perl is not an acronym, apocryphal folklore and post-factoexpansions notwithstanding..Sh "Is it a Perl program or a Perl script?".IX Subsection "Is it a Perl program or a Perl script?"Larry doesn't really care. He says (half in jest) that \*(L"a script iswhat you give the actors. A program is what you give the audience.\*(R".PPOriginally, a script was a canned sequence of normally interactivecommands\*(--that is, a chat script. Something like a \s-1UUCP\s0 or \s-1PPP\s0 chatscript or an expect script fits the bill nicely, as do configurationscripts run by a program at its start up, such \fI.cshrc\fR or \fI.ircrc\fR,for example. Chat scripts were just drivers for existing programs,not stand-alone programs in their own right..PPA 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 \fIprogram\fR has been compiled to physical machine codeonce and can then be run multiple times, whereas a \fIscript\fR must betranslated by a program each time it's used..PPNow that \*(L"script\*(R" and \*(L"scripting\*(R" 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 \*(L"non serious\*(R" or \*(L"not real programming\*(R". Consequently, some Perlprogrammers prefer to avoid them altogether..Sh "What is a \s-1JAPH\s0?".IX Subsection "What is a JAPH?"(contributed by brian d foy).PP\&\s-1JAPH\s0 stands for \*(L"Just another Perl hacker,\*(R", which Randal Schwartz usedto sign email and usenet messages starting in the late 1980s. Hepreviously used the phrase with many subjects (\*(L"Just another x hacker,\*(R"),so to distinguish his \s-1JAPH\s0, he started to write them as Perl programs:.PP.Vb 1\& print "Just another Perl hacker, ";.Ve.PPNote the trailing comma and space, which allows the addition of otherJAxH clauses for his many other interests..PPOther people picked up on this and started to write clever or obfuscatedprograms to produce the same output, spinning things quickly out ofcontrol while still providing hours of amusement for their creators andreaders..PP\&\s-1CPAN\s0 has several \s-1JAPH\s0 programs at http://www.cpan.org/misc/japh ..Sh "Where can I get a list of Larry Wall witticisms?".IX Subsection "Where can I get a list of Larry Wall witticisms?"(contributed by brian d foy).PPGoogle \*(L"larry wall quotes\*(R"! You might even try the \*(L"I feel lucky\*(R" button.:).PPWikiquote has the witticisms from Larry along with their source,including his usenet postings and source code comments..PPIf you want a plain text file, tryhttp://www.cpan.org/misc/lwall\-quotes.txt.gz ..Sh "How can I convince others to use Perl?".IX Subsection "How can I convince others to use Perl?"(contributed by brian d foy).PPAppeal to their self interest! If Perl is new (and thus scary) to them,find something that Perl can do to solve one of their problems. Thatmight mean that Perl either saves them something (time, headaches, money)or gives them something (flexibility, power, testability)..PPIn general, the benefit of a language is closely related to the skill ofthe people using that language. If you or your team can be more faster,better, and stronger through Perl, you'll deliver more value. Remember,people often respond better to what they get out of it. If you runinto resistance, figure out what those people get out of the otherchoice and how Perl might satisfy that requirement..PPYou don't have to worry about finding or paying for Perl; it's freelyavailable and several popular operating systems come with Perl. Communitysupport in places such as Perlmonks ( http://www.perlmonks.com )and the various Perl mailing lists ( http://lists.perl.org ) means thatyou can usually get quick answers to your problems..PPFinally, keep in mind that Perl might not be the right tool for everyjob. You're a much better advocate if your claims are reasonable andgrounded in reality. Dogmatically advocating anything tends to makepeople discount your message. Be honest about possible disadvantagesto your choice of Perl since any choice has trade-offs..PPYou might find these links useful:.IP "\(bu" 4http://perltraining.com.au/whyperl.html.IP "\(bu" 4http://www.perl.org/advocacy/whyperl.html.SH "REVISION".IX Header "REVISION"Revision: \f(CW$Revision:\fR 10427 $.PPDate: \f(CW$Date:\fR 2007\-12\-14 00:39:01 +0100 (Fri, 14 Dec 2007) $.PPSee perlfaq for source control details and availability..SH "AUTHOR AND COPYRIGHT".IX Header "AUTHOR AND COPYRIGHT"Copyright (c) 1997\-2007 Tom Christiansen, Nathan Torkington, andother authors as noted. All rights reserved..PPThis documentation is free; you can redistribute it and/or modify itunder the same terms as Perl itself..PPIrrespective 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 \s-1FAQ\s0 wouldbe courteous but is not required.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -