I'm not sure I understand the question (BTW where is it?). But at least I can help you with some red flags in your script.

First of all always use strict mode and warnings in Perl. It means your scripts should start with

#!/usr/bin/perl -w use strict;

It forces you to declare all variables you are using with my. See also perldoc strict. It helps to catch a lot of errors in Perl code.

Second of all don't reinvent the wheel. Don't try to parse query params yourself - chances are that you doing it wrong. Reuse existing code. That is CGI.pm.

Instead of

$form_data = $ENV{'QUERY_STRING'}; $form_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C",hex ($1))/eg; # Replace the + char with space char. $form_data =~ s/\+/ /g; # Split $form_data into name/value pairs @fields = split (/&/, $form_data); # Init script variables with form data values # $form_name is the name from the form. # from the text fields... ($form_name, $candidate) = split (/=/, $fields[0]); ($form_name, $position) = split (/=/, $fields[1]); ($form_name, $education) = split (/=/, $fields[2]);

you should have something like

use CGI; my $q = new CGI; my $candidate = $q->param('candidate'); my $position = $q->param('position'); my $education = $q->param('education');

Let's move further

$form_name > dataform.html

You can't write data into file this way. Read perldoc perlopentut for info how you can open files and read from/write to them.

Probably you need something like:

open(OUT, "> dataform.html") or die "Can't open file: $!"; print "Candidate: $candidate\n"; print "Position: $position\n"; print "Education: $Education\n\n"; close OUT;

This writes submited data into dataform.html. Probably you need to adjust format.

Well, I hope I gave enough info to do some homework (i.e. reading docs).


In reply to Re: Trying to write a CGI script for this piece of HTML by IlyaM
in thread Trying to write a CGI script for this piece of HTML by villa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.