Perl (Practical Extraction and Report Language) is a language first designed for UNIX system administration. By borrowing heavily from C, sed, awk, and the Unix shells, Perl has become the language for many file processing and management, process management, and system administration tasks with its sophisticated pattern matching capabilities and flexible syntax. But it was not until the birth of CGI that PERL became so popular. Today no other language matches PERL's position in the CGI world. Over the years, Perl has been ported to many different platforms such as MS-DOS and Windows NT.
Unlike C and other compiled programming languages, Perl is interpreted. So we often call the Perl program "Perl script". The latest version is Perl 5.0.
#!/usr/local/bin/perl # # This is the famous Hello, world example # print 'Hello world.'; #Print the word
#!/usr/local/bin/perlwhich starts with "#!", often appears as the first line in most Perl programs (especially for CGI programs). This line tells the computer to find the Perl intepreter, then run this program when it is executed. You must specify the Perl intepreter's absolute path in the system, which usually is at the "/usr/local/bin/" directory, so that the Perl intepreter can be found correctly . This is important for CGI programs because it runs through the Internet. Of course, if you run the program in a local system in the command line, the first line is not neccessary. You can just issue the following command in your Shell:
perl hello.plIt works well either with or without the first line. But for a CGI program, the first line is neccessary.
If you do not know the directory in the system, you can use the:
which perlcommand to check the directory in which directory Perl resides.
perl hello.pl
Chmod 755 hello.plThen issue the command:
hello.pl
chmod 755 hello.plThen include it in HTML form as we talked before:
<form method=post action="/cgi-bin/hello.pl> </form>