Perl

  • 分類語彙表で利用
    	#!/usr/bin/perl
    	use CGI;
    	my $charset="utf-8";
    	my $title="小樽商科大学";
    	my $myself = './***.cgi';#<------------------修正
    	my $q = new CGI;
    	print $q->header(-charset=>$charset);
    	print $q->start_html(-title=>$title, -encoding=>$charset);
    	#時間
    	my @time = localtime(time);
    	$time[4]++;
    	$time[5] += 1900;
    	print "<br>$time[5]年$time[4]月$time[3]日$time[2]時$time[1]分$time[0]秒<br>\n";
    	print "$ENV{'REMOTE_ADDR'}<br>\n";
    	#入力単語
    	print "入力:" . $q->param('user') . "<br>\n";
    	if($q->param('user')){
    	        &Log($q->param('user'));
    	}
    	print $q->start_form(-method => 'POST', -action => $myself);
    	print qq|<input type="text" size="30" name="user" value="廃止">\n|;
    	print qq|<input type="submit" name="submit" value="送信">\n|;
    	print $q->end_form();
    	print $q->end_html();
    	##############################
    	#        ログの書き込み      #
    	##############################
    	sub Log(){
    	        my $word = $_[0];
    	        #LOG
    	        open(OUT,">>log.dat");#<------------------修正
    	        print OUT "$time[5]月$time[4]月$time[3]日$time[2]時$time[1]分$time[0]秒\t$ENV{'REMOTE_ADDR'}\t$word\n";
    	        close(OUT);
    	}