top of page

Perl as a Object Oriented Scripting Language

Perl supports both procedural and object-oriented programming. Due to its open source and rich community of users, it is rapidly developing and gaining even higher popularity among developers of dynamic web applications and system administrators. Apart from its exceptional text processing features, Perl boasts support for third-party databases, such as Oracle, PostgreSQL, MySQL, etc. (quickly integrated through Perl's DBI package), and easily interfaces with external C/C++ libraries through XS or the SWIG software. Moreover, Perl can handle encrypted web data, including e-commerce transactions.


Mod_perl

Mod_perl allows a Perl interpreter to be embedded in the Apache web server. It speeds up the interpreting of each generated page (executed at the moment of opening) and the processing of the data with as much as 200%. The server load is reduced to minimum even when executing Perl scripts from the most heavily content laden websites.


Generating HTML files linked together in a slide show:

#!/usr/local/bin/perl
f ($#ARGV != 1) {
    print "usage: htmlslides base num\n";
    exit;

base = $ARGV[0];
num = $ARGV[1];
or ($i=1; $i <= $num; $i++) {
    open(HTML, ">$base$i.html");
    if($i==$num) {
        $next = 1;
    } else {
        $next = $i+1;
    }
    print HTML "<html>\n<head>\n<title>$base$i</title>\n
</head>\n<body>\n";
    print HTML "<a href=\"$base$next.html\"><img src=\"$base$i.jpg\"></a>\n";
    print HTML "</body>\n</html>\n";
    close(HTML);

Perl has adopted many borrowings from other popular programming languages - awk, sed, Lisp, etc., but is most influenced by C - it is procedural in its nature, and uses variables, expressions, control structures and sub-routines. In Perl all variables are marked with a sigil, which is usually the dollar sign ("$"), but Perl has also introduced several other sigils for arrays ("@"), hashes ("%") and sub-routines ("&"). Typical for Perl is the use of regular expressions - regex.


A simple Perl script

#!/usr/local/bin/perl
#
#
print 'Hello world.';

The latest revisions of Perl are aimed towards the simplicity of the code. Larry Wall himself is a linguist and his main task is to make the Perl syntax easier to read and understand. For example, in the last Perl version, the above example can look like this:

#!/usr/local/bin/perl
#
#
say 'Hello, world!'

Perl with NTC Hosting

NTC Hosting always aims to provide perfectly optimized solutions to its clients. This is why all our web hosting servers are optimized to support "the three P's" - Perl, Python and PHP. Perl support is included in all our hosting plans to allow you to build your desired website in your preferred programming language.



Source: ntchosting


The Tech Platform

0 comments

Comentarios


bottom of page