read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
Perhaps you could use the CGI module and do something like:
use CGI; my $cgi = new CGI; my $var1 = $cgi->param('FORM_VAR_1');
Where FORM_VAR_1 is a variable on the HTML form, and it is part of the CGI get - for example http://somesite.com/cgi/script.cgi?FORM_VAR_1=xxxx
$temp = "$table" . "ips" . ".txt"; $temp1 = "$table" . "results" . ".txt";
This can be rewritten as follows to save keystrokes... ;-)
$temp = "${table}ips.txt"; $temp1 = "${table}results.txt";
And then in the following code:
open(TABLEIP, "<$temp"); while(<TABLEIP>) { $thisline = $_; chomp($thisline); if($thisline == $ipaddress) { $IPcheck = 1; {last} } else { $IPcheck = 0; } } close(TABLEIP);
Try to use the perl module IO::File to read from a file, and the this line variable is not necessary, the string test with == is wrong, the correct syntax is eq...
use IO::File; .... $IPcheck = 0; { my $file = new IO::File "$temp", "r"; while (<$file>) { chomp; # operates on the $_ variable directly if ($_ eq $ipaddress) { $IPcheck = 1; last; } } } # note that you do not have to close the $file handle, falling # out of the scope and perl will automatically close the file.
And later in your code ...
while(<TABLERESULTS>) { $thisline = $_; $counter++; if($counter == 1) { $scoretotal = chomp($thisline); } if($counter == 2) { $votetotal = chomp($thisline); } if($counter > 2) { {last} } }
This could be written as follows...
while(<TABLERESULTS>) { $counter++; chomp; $counter == 1 ? {$scoretotal = $_} : $counter == 2 ? {$votetotal = $_} : {last} }
And so on...

The main failing in the original program would be comparing two strings with the == operator.

Looks like you still have some readings to do in perl, why not try out the tutorials on PerlMonks, and also at Perl Open Library

In reply to Re: Resources for learning Perl with CGI? by Roger
in thread Resources for learning Perl with CGI? by gotpong

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.