基本的なカウンタでハマった
1 #! /usr/bin/perl 2 3 open(IN, "< ./count.dat"); 4 $count = <IN>; 5 close IN; 6 7 ++$count; 8 9 open(OUT, "> ./count.dat"); 10 print OUT $count; 11 close OUT; 12 13 print STDOUT <<END; 14 Content-type: text/html 15 16 <html> 17 <head> 18 </head> 19 <body> 20 $count 21 </body> 22 </html> 23 END
何度、更新しても値は増えていかない。
原因はファイルcount.datのパーミッション。
$ ls -l total 16 -rw-r--r-- 1 rdera staff 2 9 30 19:29 count.dat -rwx---r-x 1 rdera staff 241 9 30 19:28 index.cgi
そりゃ、書き込みできないわ。
$ chmod 707 count.dat $ ls -l total 16 -rwx---rwx 1 rdera staff 1 9 30 19:34 count.dat -rwx---r-x 1 rdera staff 242 9 30 19:30 index.cgi
解決。初歩的でした。