PDA

View Full Version : Poll Script Errors


ficklejester
12-18-2004, 01:07 AM
there is some kind of error on the 5th line here... what is it!?...

#Open the data file again for write access (erase the file) and write
#the poll data to the file
open(POLL2, ">/same/path/to/data/file");
print <POLL2> @POLL;
close(POLL2);

iDxMan
12-18-2004, 10:41 AM
Try:

print POLL2 @POLL;


-r

ficklejester
12-18-2004, 06:29 PM
erg.. now there is an error on this:

@POLL[$answer - 1] += 1;

gsoft
12-18-2004, 09:58 PM
Can you show us all the code

ficklejester
12-18-2004, 10:16 PM
#!/usr/bin/perl

use CGI::Carp qw(fatalsToBrowser);

#get the value from the query string, and url-decode it
$buffer = $ENV{'QUERY_STRING'};
($name, $answer) = split(/=/, $buffer);

#read the poll data from an external data file
open(POLL1, "/path/to/poll/data");
@POLL = <POLL1>;
close(POLL);

#update the poll data
@POLL[$answer - 1] += 1;

#Open the data file again for write access (erase the file) and write
#the poll data to the file
open(POLL2, ">/same/path/to/data/file");
print POLL2 @POLL;
close(POLL2);

#this assumes the data is still in @POLL
print << "END_OF_HTML";
<html>
<body>


people who picked answer 1: $POLL[0]</p>


people who picked answer 2: $POLL[1]</p>


people who picked answer 3: $POLL[2]</p>


people who picked answer 4: $POLL[3]</p>
</body>
</html>

END_OF_HTML

iDxMan
12-18-2004, 10:29 PM
try:

$POLL[$answer-1]++;


-r

ficklejester
12-18-2004, 10:50 PM
still not working... can you try it on a server?? i would appreciate it so much