⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conelec1.pl

📁 小小程序....请大家慢慢看拉...就是一些关于你学习它的一些练习
💻 PL
字号:

use CGI;
use CGI ":standard";
use Fcntl qw(:DEFAULT :flock);

sub error {
    print start_html();
    print "Error - input/output error in conelec1.pl <br/>";
    print end_html();
    exit(1);
}


my($age, $gender, $vote) = (param("age"), param("gender"), param("vote"));


print header;

# Set $index to the line index of the current vote

$index = $age + $gender;

# Open and lock the survey data file

open(SURVDAT, "+<survdat.dat") or error(); 

flock(SURVDAT, LOCK_EX) or error();

# Read the survey data file, unlock it, and close it

for ($count = 0; $count <= 7; $count++) {
   chomp($file_lines[$count] = <SURVDAT>); 
}

# Split the line into its parts, increment the chosen device, and 
#  put it back together again

@file_votes = split / /, $file_lines[$index]; 
$file_votes[$vote]++;
$file_lines[$index] = join(" ", @file_votes);

# Rewind the file for writing 
seek(SURVDAT, 0, 0) or error();

# Write out the file data and close it (which also unlocks it)

foreach $line (@file_lines) {
    print SURVDAT "$line\n";
}

close(SURVDAT);

# Build the web page to thank the survey participant

print start_html("Thankyou");
print "Thank you for participating in our survey <br/> <br/> \n";
print end_html;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -