#!/usr/local/bin/perl #指定したディレクトリ内のテキストファイルをリストしてリンクを張ります。 $title = 'TEXT-リンカ'; #リストするディレクトリ $dir = "./"; #テキストにリンクしたのリスト要素 @entrylist; #指定したディレクトリを開く opendir(DIR,$dir) || &error("ディレクトリ【$dir】にアクセスできません。"); while ( $entry = readdir DIR ) { #拡張子「txt」を持つファイルだけリストに追加する if($entry =~ /\.txt/){ push @entrylist,"
  • $entry
  • \n"; } } closedir(DIR) ; print "Content-type: text/html\n\n"; print <<"EOF"; $title

    $title


    テキストファイルの一覧


    EOF #リストを表示する if(@entrylist){ print "\n"; }else{ print "指定したディレクトリにテキストファイルは見当たりません"; } print ""; exit; ########################################################### #エラー表示 sub error { #ローカル変数の設定 #@_は引数の配列 local (@msg) = @_; local ($i); print "Content-type: text/html\n\n"; print <<"EOF"; $_[0]

    $_[0]

    EOF print "\n"; print "\n"; exit; }