#!C:/Perl/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; use Fcntl qw(:flock :seek); my $outfile="poll.txt"; if(param('club')){ open(POLL,">>$outfile") or dienice ("Can't open poll.txt: $!"); flock(POLL, LOCK_EX); seek(POLL,0,SEEK_END); print POLL param('club')."\n"; close(POLL); } #redirect to result.cgi print redirect ("http://10.20.91.122/cgi-bin/results.cgi"); sub dienice { my($msg) = @_; print header; print start_html("Error"); print h2("Error"); print $msg; print end_html; exit; } #### #!C:/Perl/bin/perl -wT use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use strict; use Fcntl qw(:flock :seek); print header; print start_html; my $outfile="poll.txt"; open(POLL,"$outfile") or dienice("Can't open $outfile:$!"); #set a shared lock on the file flock(POLL,LOCK_SH); #seek the beginning of the file seek(POLL,0,SEEK_SET); my(%count,$total_count); $total_count=0; foreach my $i ("mutd","che","ars","liv","none"){ $count{$i}=0; } while(my $rec=){ chomp($rec); $total_count = $total_count+1; $count{$rec} = $count{$rec}+1; } print <Which is your favorite club?
Manchester United $count{mutd} votes
Arsenal $count{ars} votes
Chelsea $count{che} votes
Liverpool $count{liv} votes
Others $count{none} votes
END print end_html; sub dienice { my($msg) = @_; print h2("Error"); print $msg; print end_html; exit; }