Arthes has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm new to web-designing and I started studying HTML and CSS (Head First HTML n CSS)...Now I'm done with that, I wanted to learn about dynamic webpages...and is it possible to use only PERL without the knowledge of javascript or php...to create interactive webpages...? Also what is CGI, how is it related to web-designing? I'm familiar with basics of PERL, but completely new to webdesigning, so i dont have a clue...please suggest me some good tutorial or books for the same... Thanks and regards.

Replies are listed 'Best First'.
Re: Web-designing using PERL
by Anonymous Monk on Mar 26, 2012 at 08:43 UTC

    Since nobody really has yet answered this, you can create dynamic web pages with pretty much any programming language. You can do fine without Javascript. What you will be doing is generating the HTML source code with Perl (that is, outputting blocks of HTML code and using logic to fill some parts of it).

    You may also have scripts or functions that, say, take a form submission and store it into a database. (You may need to learn SQL for this.) This is very common in web applications. The database provides persistence and generally stores the values you may need to generate your HTML page.

    In addition, you need a general understanding of how the HTTP protocol works, and how your library or framework of choice (CGI.pm is perhaps the lowest common denominator, and rarely the most pleasant one to use) abstracts it. A templating language will come in handy for the HTML generation part, and most frameworks already provide one.

    Still, start small. Make a form that posts to a script that calculates some values based on the input. This is perhaps the "interactive HTML hello world" and is useful to familiarise yourself with how it works.

      Thanks a lot...Ur reply was very helpful to me...

Re: Web-designing using PERL
by CountZero (Bishop) on Mar 26, 2012 at 05:55 UTC
    Perl, (not PERL, it is not an acronym) once was (and for a large part still is) the language that makes the interwebz hum and buzz.

    PHP is nothing but a glorified templating language that was originally written in Perl.

    And Javascript is something that runs on the client computer and most likely therefore still needs an engine that runs on the server and there is a good chance Perl will be the language that runs on the server.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      not PERL, it is not an acronym
      You do know that the perl manual page disagrees with you, don't you? From the current blead:
      =head1 DESCRIPTION
      
      Perl officially stands for Practical Extraction and Report Language, except when it doesn't.
      
      ...
      
      Perl actually stands for Pathological Eclectic Rubbish Lister, but don't tell anyone I said that.
      
      Are you doubting the written words of Larry? The last phrase actually dates from the manual page of Perl 1.0. Which also mentions Practical Extraction and Report Language. Except that it does so in the NAME section, not the first line of DESCRIPTION.

      Only if you send in a patch to p5p to remove the acronyms from the documentation, and get the patch accepted, I'll belief any claims Perl isn't an acronym. Otherwise, it's just your word against Larry's (who has the backing of p5p), and their word carries a lot more than yours.

        That's a very selective reading. See also perlfaq1, and the lack of all-caps in the very first portion of the documentation you quoted. (Or ask Larry.)

Re: Web-designing using PERL
by tobyink (Canon) on Mar 26, 2012 at 12:46 UTC

    For most websites, HTML (or XHTML) is the most important thing you'll be serving up.

    That HTML might be static (i.e. you write the HTML on your computer, upload it to your server, and it becomes part of your site) or dynamic (i.e. you write a script on your computer, upload it to your server, and the script produces HTML as its output).

    You can generally write such scripts in whatever programming language your server will be able to run. Perl is one such language - and I'd expect it to be the first choice of most of the monks here.

    You'd typically then supplement the HTML with CSS to control how it looks, and possibly with Javascript to control the behaviour of the pages (e.g. make forms more interactive, add drop-down menus, etc).

    What is CGI? It stands for Common Gateway Interface. It's a standardised set of conventions for a web server (such as Apache) to "talk" to a script. It basically involves the server stuffing a bunch of useful information into environment variables, executing the script, reading data from the script's STDOUT, and sending that data back to the browser.

    CGI.pm (see CGI) is a Perl module that makes it easier to write scripts that will be spoken to via CGI. It deals with extracting data from environment variables, etc.

    CGI is just one way that a web server can talk to your script. Although it's simple, flexible, very widely supported, and well-known, it does also have its drawbacks. Each request for a page will run your script fresh. If your script needs to do a lot of initialisation (e.g. loading modules, opening database connections, etc) this can be pretty slow - it can be preferable to have a script which starts once and is able to serve up many pages. Solutions like mod_perl and FastCGI can help here.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Hi tobyink, Thanks for the info...I think learning about how the http works will be a good start to me...Then I can try on CGI.

        how can i use PERL for Web designing.
Re: Web-designing using PERL
by bms (Monk) on Mar 26, 2012 at 07:23 UTC

    Without playing too much with semantics, yes. You can have dynamic webpages using Perl. This website is a testament to that. But it's limited if you want to create web apps that emulate desktop apps. Javascript is your best bet there. But as a server sided language, Perl rocks. For templating, Perl rocks. Just need to throw a little javascript in the pot if you want truly responsive uis like Gmail.

      Hi bms, Thanks for the reply...I cudn't understand what you mean by "emulate desktop apps"...can you give me a simple example...

        Think Google Docs.
Re: Web-designing using PERL
by mendeepak (Scribe) on Mar 26, 2012 at 05:18 UTC

      Hi mendeepak, Thanks for the reply...I'll check it...