#!/usr/local/bin/perl &decode; &filetest; sub filetest{ my($aboard) = 0; my(@bmax) = (); my(@bcount) = (); my(@groups) = (); my(%boards) = (); my(%urls) = (); my($i, $j, $k) = (0, 0, 0); my($seed) = $in{'seed'}; unless(exists $in{'seed'}){ $seed = 722456;} my($heats) = $in{'heat'}; unless(exists $in{'heat'}){ $heats = 24;} my($script) = 'make.cgi'; open(BDT ,"boards2.txt"); while(){ chomp; my($input1, $input2, $input3) = split(/<>/, $_); $boards{$input2} = $input3; $urls{$input2} = $input1; ++$aborad; } close BDT; for($j=0;$j<$heats;$j++){ if($j < $aborad%$heats){ push(@bmax, int($aborad/$heats)+1);} else{ push(@bmax, int($aborad/$heats));} push(@bcount, 0); push(@groups, ''); } srand $seed; foreach(keys %boards){ my($bname) = $_; while(1){ my($group) = int(rand($heats)); if($bcount[$group] < $bmax[$group]){ $groups[$group] .= "$bname:"; $bcount[$group]++; last; } } } print <<"EOH"; Content-type: text/html 組み合わせ抽選のテスト
組み合わせ抽選のテストです。
seed=$seed

あくまでこの表\示はテスト用です!
実際の組み合わせは、運営スレ上で使用する乱数の種が決定されて、
その上で抽選が行われます。

EOH print "
\n"; for($j=0;$j<$heats/8;$j++){ print ""; } print "
\n"; print "\n"; foreach($k=0;$k<8;$k++){ print "
\n"; printf("\n",'一時予選',$j*8+$k+1); foreach(sort split(/:/,$groups[$j*8+$k])){ print ""; print "\n"; } print "
%s%02d組
$boards{$_}0
\n"; } print "
\n"; print "
\n"; print "\n"; } #--------------- # デコード処理 | #--------------- sub decode{ my($encoding) = @_; $method = $ENV{'REQUEST_METHOD'}; local($query, $key, $val, @in); if($method eq 'GET') { $query = $ENV{'QUERY_STRING'}; } elsif($method eq 'POST') { read(STDIN, $query, $ENV{'CONTENT_LENGTH'}); } local(@query) = split(/&/, $query); foreach(@query){ tr/+/ /; ($key, $val) = split(/=/); # %HH 形式の部分のデコード $key =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("c", hex($1))/ge; $val =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("c", hex($1))/ge; $val =~ s/\r\n/\n/g; # jcode.pl を使うときは#をはずす... #jcode'convert(*key, $encoding) if ($encoding); #jcode'convert(*val, $encoding) if ($encoding); $in{$key} = $val; } return *in; }