Perl is an interpreted language and stands for Practical Extraction and Report Language (language for practical data extraction and reporting).
With Perl, for example, you can create a script that opens one or more files, processes information, and writes the results.
Perl is a great tool for communicating with web servers through the Common Gateway Interface (CGI), a common communication interface.
Perl commands can easily get data from an HTML form or other source and do something with it.
Another programming language that not only had its popularity in the past but is still used by web developers today is Perl. The name of the language stands for - "a practical language for data extraction and reporting". Perl provides ample opportunities for developing concise and efficient applications, system programs.
Providing hosting for Perl doesn't require any special features. Perl-enabled hosting works in two ways - CGI or mod_perl. The language is characterized by its speed and reliability. Perl distributions are available for all platforms. If we consider it in a promising direction, then all hopes are associated with the release of the sixth version of the language. Also, the prospect is the use of modern Perl frameworks, for example, Catalyst.
A feature of this programming language is the CPAN module library, which is common for all hosting users. It contains a large amount of documentation and software. The quality and performance of Perl hosting depend on this content.
Perl is a programming language called Perl, which allows you to create dynamic web pages such as bulletin boards.
Perl is a programming language that uses the mechanism of CGI on a web server. By executing a program written in Perl language, CGI can be started and a dynamic web page can be created.
It should be noted that if the CGI runs out of control on the rental server (shared server) and the server goes down, usage restrictions may occur.
CGI is an abbreviation for [Common Gateway Interface], which is a server-side program that creates dynamic web pages such as bulletin boards and chats. By using CGI, you can create dynamic web pages using programming languages such as Ruby, Python, and Perl. You can create an original access counter or shopping cart and publish it on the website. It is currently used by many web servers. CGI can be used in any language, including Perl, Ruby, and C, but the most popular is the Perl language.
Perl Hosting Background
Perl is an abbreviation for [Practical Extraction and Report Language], which is a programming language that can run on many platforms such as UNIX OS and Windows OS. The language was developed by Larry Wall in 1987. It is widely used as a development programming language for web application creation, system management, text processing, etc. In particular, it excels in file processing such as text search and extraction. Perl belongs to the scripting language among programming languages.
Perl's notation is similar to C but incorporates the great features of C and other programming languages such as sed, awk, and shell scripts. Since it is an interpreter type that does not require compilation processing (converting to a format that can be executed on a computer), it can be executed immediately after writing a program.
It is capable of high-speed processing even in scripting languages and has high backward compatibility (compatibility with older versions).
You can also add new functions as a module. For example, Benchmark, base, Encode, utf8, file:: Basename, File: Copy, File: Path, File: Spec, File: Temp, Net: FTP, Scalar: Util, Storable, Sys: It can be said that it is also a big feature that there are many modules that can be used as standard such as Hostname, Time: Piece, FindBin, etc.
It is also cross-platform and can run on most types of servers, including UNIX-like operating systems, Windows-based operating systems, Mac OS, Linux OS, and web servers such as Apache and IIS.
As an aside, the developer said that in addition to the Practical Extraction and Report Language, which means "practical data acquisition report creation language," it also has the hidden meaning of Pathologically Eclectic Rubbish Lister, "pathologically grievous junk output device."
How CGI web hosting works in Perl?
The term CGI comes from the Common Gateway Interface. It is just another designation for what we know as API (Application Programming Interface). Summary of the story, CGI is just an API for the webserver.
The web server, in turn, is the software that sends web pages to web browsers (browsers such as Internet Explorer or Netscape). Technically, browsers should be called web clients and the people who use them should be called browsers.
There is a lot of information about CGI on the Internet, however, most of the time, mismatched and full of myths and prejudices. Let's clarify some doubts by reporting what is not CGI.
CGI is not a programming language: this means that you can use any language of your choice to write a CGI program. It is clear that the chosen language needs to be able to read an "input" and write an "output". Do you know any programming language that does not offer such possibilities?
You don't need the Perl language. Perl can be used just like any other language, such as PHP, C, Phyton, Object Pascal, etc. It's not just for experts on Unix systems. In fact, there is no need to be an expert, basic programming skills are more than enough.
It is not a programming style. Use your own style, because only with "input" and "output" can we make the web server "chat" with CGI.
It sounds like a joke, but a web server just waits - unless the site is being massively accessed.
What the web server is waiting for is nothing more than a client, a browser that requests a file. This file can be an HTML page, a graphic, or any other type of file.
When the web server receives a request, it performs three tasks in the following order:
Send a line of shallow text that contains the type of file to be sent, that is, HTML, GIF, JPEG, or any other;
Send a blank line;
Sends the contents of the file.
How does the Web Server send files?
One at a time. Amazingly, just one.
We know that a typical web page consists of an HTML document and some graphics. Each of them is a different file that needs to be sent to the browser. As the web server sends only ONE file at a time, the browser needs to start a new session (request) for each of the files it needs. Thankfully, both the web server and the browser are multi-tasking. The browser can request several files simultaneously and the web server can send several files simultaneously, however, for each of the requested-sent files, a separate session is required.
Is the web server only capable of sending files?
Not necessarily. In fact, what happens is just a data transfer. Remember that the server and the client (the browser) usually run on different computers. They can even use different operating systems on machines with different microprocessors. The browser only requests a "resource" and does not know, nor does it need to know, where the server gets the data from.
However, a typical server is programmed to obtain its data from a file. It simply reads the data from the file and transmits it to the client. As a result of this process, the server sends only static data, that is, the server does not dynamically change the data sent.
What to do to send dynamic data?
It is not at all difficult. CGI was designed precisely to fulfill this function. You simply write a program that produces data dynamically and this data, instead of a file, is sent to the browser.
This is how a CGI program extends the functionality of a server, in the same way that, for example, a DLL extends the functionality of Windows. But there is a big difference: CGI is much simpler to write than anything for Windows.
But, how to talk to the browser?
There is no need to speak to the browser. It is the server that does this job. The best part of the game is that you don't even need to talk to the server. All you have to do is write to standard output (standard output). In the same way, as, for example, you use printf () from the C language.
The only thing that cannot be lost sight of is the sequence of the three tasks performed by the server in a data transmission (mentioned above). Since the server does not know the type of data you will be sending, you need to supply the standard output with this information.
It was said above that you can use your own style. Well, come on: suppose your server is running under DOS. As a matter of fact, there is no server like that but there are Windows servers and Windows can interpret MS-DOS commands. So, imagine that you want to send a list of your current directory to the web (not a good idea, but it shows how simple this task is). MS-DOS also has the direct command that sends the directory listing to standard output. So, theoretically, we could produce the following script:
1. Task: identify the type of data that will be sent:
2. Task: send a blank line:
3. Task: send the content:
The above example is just a simulation of how a CGI script works using elements that most people know about. It was quoted just to understand the principle of output and not to actually work. Now, one more step...
How to get input?
First of all, it needs to be very clear that the web is not interactive. This means that your CGI program cannot request inputs from users, process them, send some results (output), ask for another input, etc.
This is precisely why programming a CGI is very simple. The program receives input from the user only once, right at the beginning, and sends only one response (output). However, both the input and the response can be of any size and complexity, depending on what your program may hold.
That said, you need to know that your program can receive user input in two ways, depending on the method the browser uses to send it to the server.
Where does the browser find user input?
The browser accepts input using HTML forms. A form can instruct the browser to send data using two methods: GET and POST.
The GET method sends the entries as part of the URL. The POST method sends the entries as stdin. The second method seems to have some advantages:
It is possible to send more data (the URL has a size limit);
The data are not recorded in log files. For example: sending a password as part of a URL leaves a trail on the various systems that the data is passing through!;
The data does not appear in the browser's address field. Again, showing a password in the browser may not be to the user's liking.
How do I know which method is being used?
The web server, before loading its CGI program, initializes some context variables. You can analyze these variables to know the quantity and the source of the input data.
One of the context variables is REQUEST_METHOD. Its value can be POST, GET, and, eventually, HEAD.
If REQUEST_METHOD indicates POST, the CONTENT_LENGTH variable will indicate how many bytes of data should be read through stdin and the CONTENT_TYPE variable will indicate that the data originates from a form (or possibly from some other source).
Once the data has been received (read by the server), it can be immediately processed and the response (output) can be sent via a stdout. The answer is usually written in the form of HTML data, with all necessary formatting. But CGI programs can produce any type of response, such as a GIF file or anything else.
This is the reason why you need to indicate to the browser, in the first 2 stages of the transmission, the type of data that will be sent. We can identify HTML data by sending the Content-type string: text/Html (task 1) followed by an empty string (task 2). Using the C language it would be printf ("Content-type: text/Html\n\n"); where \n is a line break and the second\n another line break to indicate the empty line.