To write the perl scripts first thing is that its not necessasory that it should be write in the perl .It can be written in any langauge like C, C++,shell scripts etc
    But as perl is rather simpler so thats why i m trying to write in perl.
    CGI are widely haaa
used to process the forms in websites.

    So first i learn how to use the forms in web page .There are generally two methods to work with forms


    Form in html pages are used in <FORM tag as shown below

                    <FORM ACTION="http://www.site/your_script"
                                   METHOD=POST>
                                                  ...
                              </FORM>
here   "http://www.site/your_script"  this is url of your script.Below i show the list of the form values with how they look like.

       Text line:         <INPUT TYPE="text" NAME="vble_name1" SIZE=30 MAXLENGTH=50>
         This yields a one line entry box where the user can enter text. SIZE is the length (in characters) of the
         displayed text. MAXLENGTH is the number of characters the text line will accept. Whatever the user
         types will be passed to your script as the value of vble_name1.

         Password:
         <INPUT TYPE="password" NAME="vble_name2" SIZE=30 MAXLENGTH=50>
         Same as a text line, except the text won't be visible to the user as she types it. Try it.

         Text area:
         <TEXTAREA NAME="vble_name3" ROWS=2 COLS=30>Default text. </TEXTAREA>
         This form tag is actually a region. It yields a scrollable text box, ROWS high and COLS wide. The default
         text is optional and can be edited by the user.

         Check box
         <INPUT TYPE="checkbox" NAME="vble_name4">
         A simple on/off flag. If the user checks it, the variable is on or true; otherwise, it is empty, or false. In your
         script, you would use this like if vble_name4 is true, then ...

         Radio buttens:Hehe Haha Hoho HeheHahaHoho

         <INPUT TYPE="radio" NAME="vble_name5" VALUE="he" checked>Hehe
         <INPUT TYPE="radio" NAME="vble_name5" VALUE="ha">Haha
         <INPUT TYPE="radio" NAME="vble_name5" VALUE="ho">Hoho
         The user makes a single selection. Notice there is one input tag for each choice. They all have the same
         name but different values. In your script, this variable can take on only one of the values specified here (or
         perhaps no value): if vble_name4 equals he, then .... You can also "check" an initial
         default selection for the user. You still need to describe each button to the user with some text (Hehe).
         The values are often abbreviations for the descriptions.
 

         Selection List:
         <SELECT SIZE=2 NAME="vble_name6">
         <OPTION SELECTED> ooh
         <OPTION> eeh
         <OPTION> aah
         </SELECT>
         Another form region. You can select a default for the user. Unlike radio buttons, the descriptions are also
         the possible values. If size is not specified, you get a popup menu instead. (If you have 100 choices, do not
         use a popup, since some of the choices will be off the screen.) Add a MULTIPLE attribute in the
         <SELECT> tag if you want to allow users to select more than one choice.
 

         Submit and Reset:
         <INPUT TYPE="submit" VALUE="Ok, let's go">
         <INPUT TYPE="reset" VALUE="Oops, start over">
         You need a SUBMIT button so the user can send the data back to the server. RESET is optional and
         clears all the user's answers. VALUES specify the text that will be displayed in the button. These don't do
         anything on this page.
 

         Hidden:
         <INPUT TYPE="hidden" NAME="vble_name7" VALUE="I am invisible.">
         A form tag that won't be displayed at all to the user. (So I can't display an example of it.) But it's useful for
         passing information to the script that you don't want the user to see, such as preserving state information
         from previous pages. It's not secret though, since it's available if she views the source of the web page.
 

        Now again returns to the METHOD
        The METHOD specifies the HTTP method to be used to submit the form information to the server.
         METHOD can have two arguments:
 

                  ISINDEXqueries.                 although you must be sure your HTTP server supports the POST method.
 
 

       and in my scripts i use the POST method . bacause it is useful for big forms, for forms that include files sent from the
        browser (using file upload), or for document   written in non ASCII characters (for example, Japanese or Hebrew).
 
 
 

        A CGI Script in Perl

          When the user submits her form data, the browser bundles all her answers up in a package and sends it to the
      script whose URL was specified in the ACTION attribute. CGI is the language or protocol used to construct
      this bundle and a script that knows how to unconstruct the bundle is a CGI script.

       The Preamble

      A Perl CGI script should always begin with the following line:

          #!/usr/bin/perl
    The line is mandatory for all Perl scripts. You may need to change the path to Perl for your site

       print "Content-type: text/html\n\n";

      This line begins some work. The web server knows it is executing a script, but has no idea what to expect in
      return. So the script must first tell the server what is coming, usually a web page of some sort. The print
      command simply writes back to whoever executed it, the web server in this case. It sends the magic words
      indicating a web page is about to follow. After the server sees this, it will pass the contents of further print
      statements back to the browser. This is how a script can return a web page.
 

      Reading the CGI Data

      To read the user's form data into your script, it's as simple as this:

          &ReadParse;
        I use this function to read the data from the page. This function is from the standard cgi-lib.pl but i make some changes
        acccording to me.
        it is as

        sub ReadParse {
        local ($i,$key,$val);

        if($ENV{'REQUEST_METHOD'} eq "POST"){
            #If we need we can compare with GET also
                     read(STDIN,$Hash,$ENV{'CONTENT_LENGTH'});
            }

        @Hash = split(/&/,$Hash);
        foreach $i (0 .. $#Hash){
         $Hash[$i] =~ s/\+/ /g;
     ($key,$val) = split(/=/,$Hash[$i],2);

     $key =~ s/%(..)/pack("c",hex($1))/ge;
     $val =~ s/%(..)/pack("c",hex($1))/ge;

     $Hash{$key} .= "\0" if (defined($Hash{$key}));
     $Hash{$key} .= $val;
     }
     return length($Hash);
    }
 

      Building a Response Page

          We can now start processing the form data in the script. In this case, we'll simply return a page reporting what
      the data was. To do this, we first need to start building the HTML source for a web page, to return to the web
      server that called the script. Recall Perl's print function does this:
          print "<title>The Response</title><h1>The Response</h1><hr>";
          print "Here is the form data:<ul>";

      We want an unordered list of the variable names and corresponding values that the user submitted. This is just
      the keyword and its corresponding value in %in. Rather than code each keyword by hand, Perl has some
      built-in functions and control loops that make this easy to do, and also means this script will work with any
      web form. So you can specify this script as your target ACTION in the form tag when you try building your
      own web form. (That's an important point -- read it again. You'll find this simple script is quite useful for
      debugging a web form.)
        Perl's built-in function, keys, returns a list of all keywords in an associative array. Then, Perl's foreach
      function will cycle through every element in an array, and execute a block of code once each time. Here it is:

          foreach $key (keys %in) {
              print "<li>$key: $in{$key}";
          }
          print "</ul>";

    Putting the CGI in your directory

            I put my CGI files in the cgi-bin directory .note that you should change the mode of CGI scripts to
                755 so that they can work other wise it will give you the error like permission denied.

        some scripts written by me