|
Previous< 7 8 9 10 11 12 13 14 15 16 17 >Next |
|
Perl is the Swiss Army chainsaw of scripting languages: powerful and adaptable. It was first developed by Larry Wall, a linguist working as a systems administrator for NASA in the late 1980s, as a way to make report processing easier. Since then, it has moved into a large number of roles: automating system administration, acting as glue between different computer systems; and, of course, being one of the most popular languages for CGI programming on the Web
|
|
|
|
Created in 1987 by Larry Wall, the UNIX based language has evolved into a powerful tool for the internet. It was designed as a quick-fix patch program for UNIX based systems. The language is very simplistic, offering optimum flexibility, perfect for short, straightforward scripting.
Since then its popularity has increased due to its flexibility, portability, usefulness, and its varied features. To get started, load a simple text editor program and follow along in our examples.
|
|
|
|
Comments can be inserted into a program with the # symbol, and anything from the # to the end of the line is ignored (with the exception of the first line). The only way to stretch comments over several lines is to use a # on each line.
Everything else is a Perl statement which must end with a semicolon, like the last line above.
|
|
|
|
The following code prints apples and pears using concatenation:
$a = 'apples'; $b = 'pears'; print $a.' and '.$b;
It would be nicer to include only one string in the final print statement, but the line
print '$a and $b';
prints literally $a and $b which isn't very helpful. Instead we can use the double quotes in place of the single quotes:
print "$a and $b";
The double quotes force interpolation of any codes, including interpreting variables. This is a much nicer than our original statement. Other codes that are interpolated include special characters such as newline and tab. The code \n is a newline and \t is a tab |
|
|
|
. To learn how to get a Perl script installed and running, we'll use the simple script below. When it is run, it will produce a web page with some simple text on it. To begin, copy and paste the script below into your favorite text editor (Notepad, Word, etc.):
Now, you will need to know where Perl is on your web server. This is because you may need to change the top line in this script. If you are unsure where Perl is, ask your web host or telnet your server and type the which perl command at the prompt:
|
|
|
|
Previous< 7 8 9 10 11 12 13 14 15 16 17 >Next |
|
|
|