PSGI and Perl

For this week I made a research on PSGI or Perl Web Server Gateway Interface. It`s a interface that allows interaction between Web servers and Perl-based Web applications. I find very interesting the following fact – PSGI makes it possible to write applications that can be run as standalone servers.

A PSGI application is a Perl subroutine (portion of code within a larger program that performs a specific task and is relatively independent of the remaining code; also called method, function, etc.) that accepts arguments as a single hash reference and returns a reference to an array of three elements: HTTP status code, HTTP headers and HTTP body lines (usually a HTML document).

Let`s take a brief overview of what Perl is.
In computer science Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in the not so distant 1987. It acted as a general-purpose Unix (a multitasking, multi-user computer operating system) scripting language to make report processing easier. After many changes during the years it became extremely popular amongst programmers. Perl borrows features from other programming languages including C. The language provides powerful text processing facilities without the arbitrary data length limits of many Unix tools, giving the opportunity of easy manipulation of text files. Perl gained widespread popularity in the late 1990s as a CGI (Common Gateway Interfacea standard that defines how web server software can delegate the generation of web pages to a text-based application) scripting language.

How a simple server in Perl works (example):

The program opens a socket and binds it to the port you specified in the command line then it waits for the client commands. The client can be anyone connecting
through telnet or a specific client.

This is an example “hello world” PSGI application:

my $app = sub {
    return [200, ['Content-Type' => 'text/plain'], ["hello, world\n"]];
Perl Web Server Gateway Interface
Subroutine (in computer science)
Perl programming language
Unix OS
Common Gateway Interface
Simple Perl server
This entry was posted in Week 5. Bookmark the permalink.

2 Responses to PSGI and Perl

  1. mbnielsen says:

    Are you planning on learning perl?

  2. Tomislav says:

    Hm.. maybe, don`t know yet =D

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s