Finally, we can get this masterpiece. I did not hesitate to purchase this little camel book online because I had switched to the second version. But when I first got it, I always wondered if I had made a wrong book. Because the first chapter of the second edition was very beautiful, I gradually expanded a simple example and finally went to a program with lines. I introduced idea very much, but I have no chance to review it this time. The first chapter is about Perl. Only a small example of five rows is listed at the end. Although I feel a sudden decline, I still have little enthusiasm for Perl. I still need to read a book from the beginning, instead of having to flip the book every time I write a textbook. Although I can complete the task, I can't remember it. Now I have made up my mind to start from scratch. Hope you can complete this book!
Start learning!
I will not start with a program. I will first talk about what perl learners must know. The inventor of Perl: Larry Wall. This is a very enthusiastic person. I have always set the Perl maillist, and I often see Larry Wall answering questions from many enthusiasts. It is concise and humorous. I believe that maillist users will be deeply touched. And he makes sure Perl is always free! How can we not support him or the cute Perl! CPAN is also the "hypermarket" of the Perl community ". It contains everything about Perl: the source code of Perl itself, Perl of the binary version on each platform, examples, documentation, and Perl extensions (almost all Perl modules can be found on it) and Perl message files. The URL is: http://www.cpan.org/, of course our Linux community also has its mirror site: http://cpan.linuxforum.net /. The last point is that Perl does not need to be compiled for execution like C, C ++, or Java. Perl can run your program by adding executable permissions. Well, it's more concise than the book.
Chapter 1 has two programs, and the first one is the famous Hello world. I didn't want to write it here, but I wrote it for integrity:
Example 1:
#! /Usr/local/bin/perl-W
Print "Hello, world! /N ";
Very simple. The real program is just one line (the second line ). The first line is written by every Perl program. Where is Perl in your system, you can use which or whereis to find it. Generally, they are in/usr/bin/Perl or/usr/local/bin/Perl. -W is my habit. This is a very good parameter. It will point out where your program is not standardized and should be noted. We recommend that you add it as well. Only the benefits are good. ^_^. I think everyone can understand the second sentence. (/N indicates a line feed)
Example 2:
#! /Usr/local/bin/perl-W
@ Lines = 'perldoc-u-F atan2 ';
Foreach (@ lines ){
S // W <([^>] +)> // U $1/g;
Print;
}
This example is very Perl-like. A bunch of symbols make you dizzy. I don't want to explain this example carefully, because it involves too much background knowledge. I posted it just to see the program execution result: Check whether your eyes are good enough ^_^. Another point should be pointed out: the second line is not a single quotation mark, but a reverse quotation mark, which can be placed in shell command!
The perldoc command is used to read and display Perl documents, related extensions, and utilities. Let's take a look at the execution result of the perldoc-u-F atan2 command:
Bash-2.05 $ perldoc-u-F atan2
= Item atan2 y, X
Returns the arctangent of Y/X in the range-pi to pi.
For the tangent operation, you may use the C <: Tan>
Function, or use the familiar relation:
Sub tan {sin ($ _ [0])/cos ($ _ [0])}
Finally, let's take a look at the program execution results:
Bash-2.05 $./ex1-3.plx
= Item atan2 y, X
Returns the arctangent of Y/X in the range-pi to pi.
For the tangent operation, you may use the POSIX: Tan ()
Function, or use the familiar relation:
Sub tan {sin ($ _ [0])/cos ($ _ [0])}
See the difference ~~~, Haha! Let's take a look at it with the program.
The exercises in the first chapter let you feel the two examples, so we won't try them out. I will work out the exercises in the future.