#!/usr/local/bin/perl
use strict;
use warnings;
use utf8;
use open ":utf8";
print "Content-type: text/html; charset=utf-8\n\n";
print "\n";
print "\n";
print "
\n";
print "CGI test\n";
print "\n";
print "\n";
print "------------------
\n";
open(FH,"+< data_rw_file0.txt") or print "file not exist
\n";
#ファイルの先頭から書き込む
print FH "加藤 みちこ\n";
print FH "東京都新宿区\n";
print FH "女性\n";
#ポインタは書き込み終了位置にある。
seek(FH, 0, 0); # ポインタを先頭へ移動しないと、書き込んだデータが表示されない。
while(my $data = ) {
chomp($data);
print "$data
\n";
}
close(FH);
print "------------------
\n";
print "\n";
print "\n";