CPS 600 Tutorial Project CPS 600 Project - Tutorial PERL

Welcome to my CPS 600 Tutorial Project– PERL You are the visitor number since February 1, 1996 to look at my Information Age project page at EST. Table of Contents How to read this tutorial Perl project? 1. Introduction to Perl 1. What is Perl? 2. Who creates Perl? 3. Perl’s license 4. Which platforms can Perl run on? 5. Where can I get Perl’s information? 6. How can I begin a perl program? 7. Is it a Perl program or a Perl script? 8. Is Perl difficult to learn? 9. Should I program …
1. Introduction to Perl 1. What is Perl? Perl is short for ” Practical Extraction and Report Language “. Perl integrates the best features of Shell programming, C, and the UNIX utilities — grep, sed, awk and sh . 2. Who creates Perl? The inventor of Perl is Larry Wall . 3. Perl’s license Perl is distributed under the GNU Public License . That means it is essentially FREE. 4. Which platforms can Perl run on? It can be run on various platforms such as UNIX, UNIX-like, Amiga, Macintosh, VMS, OS/2, even MS-DOS and maybe more in the near future. 5. Where can I get Perl’s information? You can get any information from the USENET newsgroup ” comp.lang.perl “. There is information for obtaining Perl, solving the problems, …, etc.. There are also many experts monitoring this news group including the inventor — Larry Wall. That means you might get response in a minute. 6. How can I begin a perl program? The simplest way to do it is include the following line at the beginning of your perl file: #!/bin/perl (or the path Perl located on your system) Some may have: #!/usr/local/bin/perl your program : : : With this line, the shell knows where to look for Perl to run the program. 7. Is it a Perl program or a Perl script? It’s up to you. If you prefer to call it Perl program, then call it program. If you like script more, then call it script. 8. Is Perl difficult to learn? No, it’s not. Many people(including myself) think Perl is easy to learn. There are some reasons: Since most of Perl is derived from some tools, utilities, programming languages that you may be familiar with. For example, you will think it is pretty easy for you if your are familiar with C, shell, awk or sed. You do not need to remember many things to be able to use Perl. For example, you can start your Perl script(program) by the following: #!/bin/perl print “Say Hi to Neon!”; You can get your result right away. You don’t have to compile your programs every time after you change something. 9. Should I program everything in Perl? As a matter of fact, you can do anything in Perl. You, however, should not. Why? You should use the most appropriate tool for your job. Some people use Perl for shell programming, some people use Perl to replace some C programs. Perl, however, is not a good choice fot very complex data structures. 2. Scalar Data A scalar is the simplest kind of data that perl manipulates. A scalar can be either a number or a string of characters. Numbers Even though we can specify integers, floating-poit number, …, etc.. However, internally, Perl computes only with double-precision floating-point values. Strings Single-Quoted Strings A single-quoted string is a sequence of characters enclosed in single quotes. One thing to notice, some special characters like newline will not be interpreted within a single-quoted string. For example: ‘hello’ # 5 characters ‘don\’t’ # 5 characters ‘hello\n’ # 7 characters Double-Quoted Strings As to a double-quoted string, it is much like a C string. The Backslash Escapes work within the double-quoted strings. The complete list of double-quoted string escapes is listed below: Escape | Meaning ——–+—————————————— \n | Newline \r | Return \t | Tab \f | Formfeed \b | Backspace \v | Verticle tab \a | Bell \e | Escape \cC | CTRL + C \\ | Backslash \” | Double quote \l | Lowercase next letter \L | Lowercase all following letters until \E \u | Uppercase next letter \U | Uppercase all following letters until \E \E | Terminate \L or \U
Download CPS 600 Tutorial Project CPS 600 Project - Tutorial PERL.Pdf