![](https://i0.wp.com/cgishop.net/wp-content/uploads/2022/07/txt.png?resize=1140%2C641&ssl=1)
Perl CGI テキストファイルを読み込んで書き込む
テキストファイルにコピーして*.cgiで保存
http://localhost/cgi/blog/sisoku.cgiなどのファイル名でアクセスしてください
↓–Perlのパスはレンタルサーバーなどで確認してください
#!c:/xampp/perl/bin/perl
#┌────────────────────────────────
#│テキストファイルを読み込んで書き込む
#| + - * /
#└────────────────────────────────
# logfile.txt のテキストの中身は
# 123456
# 111111
#の2段になってます
#==========ここから下がスクリプト===================================
# [ 設定 ]
$ver = ‘ Version 1.00’;
print “Content-type: text/html\n\n”;
open IN,”logfile.txt”;
@all =<IN>;
close IN;
print @all;
@all = reverse @all;
print “<br><br>”;
open OUT ,”> logfile.txt”;
foreach(@all){
print OUT $_;
}
close OUT;
print @all;
# 著作権表示(削除不可)
print <<tyosaku1;
<br><br><br><br>
<center><small>
$ver
</small></center>
tyosaku1
print <<tyosaku;
<br>
<center><small>
<a href=’https://cgishop.net/’ target=’new’>CGI Shop</a>
</small></center>
</BODY>
</HTML>
tyosaku
Last Updated on 2022年11月5日9:03 pm by cgishop
こちらもおすすめ
![](https://i0.wp.com/cgishop.net/wp-content/uploads/2022/07/変数.png?resize=500%2C380&ssl=1)
変数を使って計算してブラウザに表示する方法
2022年7月5日![新品中古のノートパソコンの選び方](https://i0.wp.com/cgishop.net/wp-content/uploads/2021/12/新品中古のノートパソコンの選び方.png?resize=500%2C380&ssl=1)
新品中古のノートパソコンの選び方
2021年12月7日![Visual Studio2022toolbar](https://i0.wp.com/cgishop.net/wp-content/uploads/2024/03/Visual-Studio2022toolbar.jpg?resize=500%2C380&ssl=1)