CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Help with script



Apr 10, 2000, 11:09 AM

Post #1 of 2 (1243 views)
Help with script Can't Post

I have the following fields in a form:

I read them into a hash like this:

if ($ENV{'REQUEST_METHOD'} eq "GET") {
} else {
$in = <STDIN>;

$in =~ s/\+/ /g;
$in =~ s/%(..)/pack("c",hex($1))/ge;


and store them in a file where it looks like this:

How would I determine the Winning team in this line?
Is this how???

if @linescore["HomeRuns"] gt @linescore["VisitRuns"] {
$winningteam = @linescore["HomeTeam"]
$winningteam = @linescore["VisitTeam"]

Administrator / Moderator

Apr 10, 2000, 3:24 PM

Post #2 of 2 (1243 views)
Re: Help with script [In reply to] Can't Post

First, numeric comparisons use > for greater than and < for less than. gt and lt are for alphabetic comparisons. Using 5 gt 10 would say that 5 is greater than 10 because 5 is asciibetically greater than 10.

Second, array elements should be accessed by a $, not a @ ($linescore[1])

Third, arrays are stored by index number as a "flat" list of elements, and are accessed by their index number (count starts from 0), not by a name. eg. the 3rd element of @linescore should be accessed by using $linescore[2]. Hashes are accessed by key name, which can be numeric or alphabetic. So if you had a hash named %linescore, you can access the value of HomeInning2 by $linescore{"HomeInning2"}.

Fourth, are you re-reading the data from your file, or are you using the form values in $in? How are you splitting your key/value pairs? Unless you're using some really cool code and my eyes aren't working right, it looks like your form input processing is incomplete, and the results are not really being stored in a hash. Is the file writing correctly? Have you tried running the program? If so, what errors are you receiving?


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives