Greetings monks,

So, I've never written a CGI before, and I'm trying to get my feet wet, so to speak. In playing around with CGI, I've discovered something that I find a bit wierd. First the code:

#!/usr/bin/perl -w use strict; use CGI qw/:standard/; print header(); print start_html("This is a test"); print start_form(); print end_form();
Pretty standard, eh? Well, when I run this, I get the following output:
Content-Type: text/html; charset=ISO-8859-1 <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"><head><title>This is a test</title> </head><body> Use of uninitialized value in length at (eval 9) line 11. <form method="post" action="/test.pl" enctype="application/x-www-form- +urlencoded">
Notice the "uninitialized value" warning. From what I've been able to ascertain, the trouble starts with the start_form sub. I looked at the documentation for CGI, and it seems like it is reasonable to call start_form sans arguments. Also, I looked at CGI.pm's source, specifically at the startform sub. I'm able to clear the warning if I provide a query string, or if I provide an action to the subroutine. Perhaps I'm making too much out of it, but I would like this to run clean under warnings. Any insight would be appreciated.
</form>

thanks in advance,
thor


In reply to CGI "uninitialized value" question by thor

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.