⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch1.htm

📁 this is a book on pearl , simple example with explanation is given here. it could be beneficial for
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>Chapter 1 -- Getting Your Feet Wet</TITLE><META></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910"><H1><FONT SIZE=6 COLOR=#FF0000>Chapter&nbsp;1</FONT></H1><H1><FONT SIZE=6 COLOR=#FF0000>Getting Your Feet Wet</FONT></H1><HR><P><CENTER><B><FONT SIZE=5>CONTENTS</FONT></B></CENTER><UL><LI><A HREF="#Origins">Origins</A><LI><A HREF="#SimilartoC">Similar to C?</A><LI><A HREF="#CostandLicensing">Cost and Licensing</A><LI><A HREF="#DoYouHavePerlInstalled">Do You Have Perl Installed?</A><LI><A HREF="#GettingandInstallingPerl">Getting and Installing Perl</A><LI><A HREF="#YourFirstPerlProgram">Your First Perl Program</A><UL><LI><A HREF="#CreatingtheProgram">Creating the Program</A><LI><A HREF="#Invocation">Invocation</A></UL><LI><A HREF="#CommentsinYourProgram">Comments in Your Program</A><LI><A HREF="#Summary">Summary</A><LI><A HREF="#ReviewQuestions">Review Questions</A><LI><A HREF="#ReviewExercises">Review Exercises</A></UL><HR><P>You are about to embark on a journey through the world of Perlprogramming. You'll find that the trip has been `made easier bymany examples liberally sprinkled along the trail. The beginningof the trip covers the basic coNCepts of the Perl language. Thenyou move on to some of the more advaNCed coNCepts-how to createPerl statements and whole programs. At the end of the trip, someguideposts are placed-in the form of Internet sites-to show youhow to explore more advaNCed programming topics on your own.<P>Do you know any other programming languages? If so, then learningPerl will be a snap. If not, take it slow, try all of the examples,and have fun experimenting as you read.<P>I thought about adding a section here about programming ideals.Or perhaps, a discussion about the future of Perl. Then, I realizedthat when I was first learning computer languages, I didn't reallycare about that stuff. I just wanted to know about the languageand what I could <I>do</I> with it.<P>With that in mind, the next section on Perl's origin is very short.After all, you can read all the background information you'd likeusing a web browser by starting at <B>http://www.perl.com</B>-thePerl Home Page.<H2><A NAME="Origins"><FONT SIZE=5 COLOR=#FF0000>Origins</FONT></A></H2><P>Perl began as the result of one man's frustration and, by hisown account, inordinate laziness. It is a unique language in waysthat cannot be conveyed simply by describing the technical detailsof the language. Perl is a state of mind as much as a languagegrammar.<P>One of the oddities of the language is that its name has beengiven quite a few definitions. Originally, Perl meant the PracticalExtraction Report Language. However, programmers also refer tois as the Pathologically Eclectic Rubbish Lister. Or even, PracticallyEverything Really Likable.<P>Let's take a few minutes to look at the external forces whichprovoked Perl into being-it should give you an insight into theway Perl was <I>meant</I> to be used. Back in 1986, Larry Wallfound himself working on a task which involved generating reportsfrom a lot of text files with cross refereNCes. Being a UNIX programmer,and because the problem involved manipulating the contents oftext files, he started to use awk for the task. But it soon becameclear that awk wasn't up to the job; with no other obvious candidatefor the job, he'd just have to write some code.<P>Now here's the interesting bit: Larry could have just writtena utility to manage the particular job at hand and gotten on withhis life. He could see, though, that it wouldn't be long beforehe'd have to write another special utility to handle somethingelse which the standard tools couldn't quite hack. (It's possiblethat he realized that most programmers were <I>always</I> writingspecial utilities to handle things which the standard tools couldn'tquite hack.)<P>So rather than waste any more of his time, he invented a new languageand wrote an interpreter for it. If that seems like a paradox,it isn't really-it's always a bit more of an effort to set yourselfup with the right tools, but if you do it right, the effort paysoff.<P>The new language had an emphasis on system management and texthandling. After a few revisions, it could handle regular expressions,signals, and network sockets, too. It became known as Perl andquickly became popular with frustrated, lazy UNIX programmers.And the rest of us.<BR><p><CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%><TR><TD><B>Note</B></TD></TR><TR><TD><BLOCKQUOTE>Is it &quot;Perl&quot; or &quot;perl?&quot; The definitive word from Larry Wall is that it doesn't matter. Many programmers like to refer to languages with capitalized names (Perl) but the program originated on a UNIX system where short, lowercase names (awk, sed, and so forth) were the norm. As with so many things about the language, there's no single &quot;right way&quot; to do it; just use it the way you want. It's a tool, after all, not a dogma.</BLOCKQUOTE><BLOCKQUOTE>If you're sufficiently pedantic, you may want to call it &quot;[Pp]erl&quot; after you've read <A HREF="ch10.htm" >Chapter 10</A>, &quot;Regular Expressions.&quot;</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><H2><A NAME="SimilartoC"><FONT SIZE=5 COLOR=#FF0000>Similar to C?</FONT></A></H2><P>Perl programs bear a passing resemblaNCe to C programs, perhapsbecause Perl was written in C, or perhaps because Larry foundsome of its syntactic conventions handy. But Perl is less pedanticand a lot more coNCise than C.<P>Perl can handle low-level tasks quite well, particularly siNCePerl 5, when the whole messy business of refereNCes was put ona sound footing. In this sense, it has a lot in common with C.But Perl handles the internals of data types, memory allocation,and such automatically and seamlessly.<P>This habit of picking up interesting features as it went along-regularexpressions here, database handling there-has been regularizedin Perl 5. It is now fairly easy to add your favorite bag of tricksto Perl by using modules. It is likely that many of the added-onfeatures of Perl such as socket handling will be dropped fromthe core of Perl and moved out to modules after a time.<H2><A NAME="CostandLicensing"><FONT SIZE=5 COLOR=#FF0000>Cost and Licensing</FONT></A></H2><P>Perl is free. The full source code and documentation are freeto copy, compile, print, and give away. Any programs you writein Perl are yours to do with as you please; there are no royaltiesto pay and no restrictions on distributing them as far as Perlis coNCerned.<P>It's not completely &quot;public domain,&quot; though, and forvery good reason. If the source were completely public domain,it would be possible for someone to make minor alterations toit, compile it, and sell it-in other words, to rip off its creator.On the other hand, without distributing the source code, it'shard to make sure that everyone who wants to can use it.<P>The GNU General Public License is one way to distribute free softwarewithout the danger of someone taking advantage of you. Under thistype of license, source code may be distributed freely and usedby anybody, but any programs derived using such code must be releasedunder the same type of license. In other words, if you deriveany of your source code from GNU-licensed source code, you haveto release your source code to anyone who wants it.<P>This is often sufficient to protect the interests of the author,but it can lead to a plethora of derivative versions of the originalpackage. This may deprive the original author of a say in thedevelopment of his or her own creation. It can also lead to confusionon the part of the end users as it becomes hard to establish whichis the definitive version of the package, whether a particularscript will work with a given version, and so on.<P>That's why Perl is released under the terms of the &quot;Artistic&quot;license. This is a variation on the GNU General Public Licensewhich says that anyone who releases a package derived from Perlmust make it clear that the package is not actually Perl. Allmodifications must be clearly flagged, executables renamed ifnecessary, and the original modules distributed along with themodified versions. The effect is that the original author is clearlyrecognized as the &quot;owner&quot; of the package. The generalterms of the GNU General Public License also apply.<H2><A NAME="DoYouHavePerlInstalled"><FONT SIZE=5 COLOR=#FF0000>Do You Have Perl Installed?</FONT></A></H2><P>It's critically important to have Perl installed on your computerbefore reading too much further. As you read the examples, you'llwant to try them. If Perl is not already installed, momentum andtime will be lost.<P>It is very easy to see if your system already has Perl installed.Simply go to a command-line prompt and type:<BLOCKQUOTE><PRE>perl -v</PRE></BLOCKQUOTE><P>Hopefully, the response will be similar to this:<BLOCKQUOTE><PRE>This is perl, version 5.001        Unofficial patchlevel 1m.Copyright 1987-1994, Larry WallWin32 port Copyright  1995 Microsoft Corporation. All rights reserved.        Developed by hip communications iNC., http://info.hip.com/info/        Perl for Win32 Build 107        Built Apr 16 1996@14:47:22Perl may be copied only under the terms of either the Artistic License orthe GNU General Public License, which may be found in the Perl 5.0 sourcekit.</PRE></BLOCKQUOTE><P>If you get an error message or you have version 4 of Perl, pleasesee your system<BR> administrator or install Perl yourself. The next section describeshow to get and<BR>install Perl.<H2><A NAME="GettingandInstallingPerl"><FONT SIZE=5 COLOR=#FF0000>Getting and Installing Perl</FONT></A></H2><P>New versions of Perl are released on the Internet and distributedto Web sites and ftp archives across the world. UNIX binariesare generally not made available on the Internet, as it is generallybetter to build Perl on your system so that you can be certainit will work. All UNIX systems have a C compiler, after all.<P>Each operating system has its own way of getting and installingPerl.<BLOCKQUOTE><B>For UNIX and OS/2</B>-The Perl Home Page contains a softwarelink (<B>http://www.perl.com/perl/info/software.html</B>) thatwill enable you to download the latest Perl source code. The pagealso explains why Perl binaries are not available. Hopefully,your system will already have Perl installed. If not, try to getyour system administrator to install it.</BLOCKQUOTE><BLOCKQUOTE>

⌨️ 快捷键说明

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