Hello you've helped me in the past and I am stuck again. Another newbie trying something new. I've created an html form and a cgi application to process the data a user will enter on this form. Being new to gaining input through a cgi form, I am getting the "use of an unititialized value" error on each line of with the print DATA command. From what I can tell, the variables are being passed from the html form to the script just fine. Before I put the CGI into use I ran it from the command line by typing this for example:

./thinner.cgi date=01/01/05 Goal_Weight=247 weight=265

and I get the error on each line that I use as a scalar for the inputed values. Below is the code, its real simple, and works if I run it from the command line using <STDIN> as my variables. Am I passing the variables into the code incorrectly? Please help I've been racking my brain and turning through every book I know to figure this out. Here is the code, the file paths are not the actual ones, but that should not matter.

#!/usr/bin/perl -w use strict; my $dfile = "/stuff/stuff/contest/me/td"; my $wfile = "/stuff/stuff/contest/me /tw"; my $gfile = "/stuff/stuff/contest/me /tg"; my %input; my $input; my $wt=$input{'weight'}; my $d=$input{'date'}; my $g=$input{'Goal_Weight'}; open (DATA,">$gfile") or die "File cannot be opened $!\n"; print DATA "$g"; close (DATA); open (DATA,">>$wfile") or die "File cannot be opened $!\n"; print DATA "$wt\n"; close (DATA); open (DATA,">>$dfile") or die "File cannot be opened $!\n"; print DATA "$d\n"; close (DATA);

janitored by ybiC: Balanced <code> tags around codeblock


In reply to My cgi nonsense. by tgolf4fun

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.