suPerlative: Why Perl Scripting?
The question breaks into two questions: why
manage a website with
scripts; and why write them in Perl ? To answer the first:-
- Automation makes it easier to create and maintain web pages.
They can be
updated very rapidly.
Some are generated from simple data files which contain the
essential text for the corresponding web pages, without the clutter
of HTML tag soup.
- Global control - easy to update whole site. To change the navigation
menu, for example, we just edit one Perl program, and then run it on all
the pages that need changing.
- Conciseness. Not only can the data files avoid some of the HTML clutter
as mentioned above, but common items can be abbreviated and the
script expands them; e.g. cross links in the
Glossary are indicated simply by
being enclosed in square brackets - the script can work out the URL
since it's internal
(example).
This conciseness makes it easier to read the content, and saves on
typing.
- Enforce standards and consistent styles,
e.g. valid HTML
in the boilerplate.
It's a good practice to follow some
style guide; it's even better to
have those recommendations encoded in a script which automatically
applies them consistently, e.g. placing navigation features on each
page. We can also ensure that the generated HTML code is readable
(go on, View Source!) and technically valid according to standards.
- Customisation flexibility - commercial packages may allow a great deal
of flexibility, but sooner or later you are likely to run into some
special case where you either can't do what you really want, or it's
hard to do. But if you have access to the source code then you are
limited only by your imagination and programming skill.
- Leveraging software resources allows you to achieve more.
Software embodies a great deal of knowledge and experience;
once a problem is solved you automatically reuse the solution and
can build on it, going farther than previously possible.
On the other hand, the cons are that you need programming skills;
need a good support environment, e.g. UNIX;
and there is some complexity to deal with, e.g. bugs in scripts.
Why Perl? Well, from the earliest days of CGI scripting, Perl was the
language of choice for most web programming projects. This was
essentially because Perl is very good at text processing, and that was
a very large part of what web applications then needed - such as
processing form entries via CGI scripts.
My (Alan's)
earliest CGI project
(in 1993) needed a decoder for form entries.
There was one available from
NCSA who had created not only
the popular
Mosaic
browser, but also a popular free
web server.
But it took 20 lines of C code; when I wrote it in Perl, it needed
only 2 lines!
suPerlative Web Construction !
suPerlative: The ht Preprocessor
|