Perl + CGI

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kriz4321
    New Member
    • Jan 2007
    • 48

    Perl + CGI

    Hi all,

    I have designed a form in which I call a perl script but the issue is "Iam not able to see the output"...
    <FORM ACTION="/cgi-bin/filecheck.pl" METHOD="post" ENCTYPE="multip art/form-data">

    Contents of filecheck.pl is

    print check;

    There are few more lines I need to add in the .pl file to make the output available on screen. Can someone help me on the same.( Iam running in Windows)

    Thanks
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    Remember that when using Perl to make CGI, you are actually printing out HTML. So you need to have all the tags necessary, like:

    [HTML]<HTML>
    <HEAD>This is a sample web page.</HEAD>
    <BODY>
    <p>This is a sample paragraph.</p>
    <br>
    </BODY>
    </HTML>[/HTML]

    You can either manually output all these tags (which will be messy and boring), or you can use some of the CGI methods imported when you 'use' it like so:

    [CODE=perl]use CGI qw/:standard/;[/CODE]

    Now many great functions are available. To generate the above HTML, I would write, in Perl,

    [CODE=perl]print start_html('Thi s is a sample web page.');
    print p('This is a sample paragraph');
    print br;
    print end_html;[/CODE]

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by kriz4321
      Hi all,

      I have designed a form in which I call a perl script but the issue is "Iam not able to see the output"...
      <FORM ACTION="/cgi-bin/filecheck.pl" METHOD="post" ENCTYPE="multip art/form-data">

      Contents of filecheck.pl is

      print check;

      There are few more lines I need to add in the .pl file to make the output available on screen. Can someone help me on the same.( Iam running in Windows)

      Thanks
      In addition to what Gannon provided, you should really open your browser, point it at Google and search for something like "CGI Perl tutorial" or something similar. There are plenty of good tutorials out there that will teach you the basics and sometimes, beyond.

      Regards,

      Jeff

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Originally posted by Ganon11
        Remember that when using Perl to make CGI, you are actually printing out HTML. So you need to have all the tags necessary, like:

        [HTML]<HTML>
        <HEAD>This is a sample web page.</HEAD>
        <BODY>
        <p>This is a sample paragraph.</p>
        <br>
        </BODY>
        </HTML>[/HTML]

        You can either manually output all these tags (which will be messy and boring), or you can use some of the CGI methods imported when you 'use' it like so:

        [CODE=perl]use CGI qw/:standard/;[/CODE]

        Now many great functions are available. To generate the above HTML, I would write, in Perl,

        [CODE=perl]print start_html('Thi s is a sample web page.');
        print p('This is a sample paragraph');
        print br;
        print end_html;[/CODE]
        You left out an important bit of information, with perl you have to print the http headers before any content is printed to the screen. If using CGI in standard more:

        Code:
        use CGI qw/:standard/;
        print header; 
        print p('This is a sample paragraph');
        print br;
        print end_html;

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          Right, I did forget that little detail, didn't I?

          Thanks Kevin.

          Comment

          • kriz4321
            New Member
            • Jan 2007
            • 48

            #6
            Thanks, It is really helpfull & will dig more into it wuth help of google....

            Comment

            Working...