저는 Perl 초보자입니다. 나는 이전의 사람의 작품과 책을 기초로하여, Learning Perl과 Modern Perl과 같은 것을 배우려고 노력하고 있습니다. HTML 폼의 데이터를 해석하고 텍스트 파일에 쓰는이 스크립트를 업데이트하려고합니다.이 작업을 다시 시작하고 다시 실행하는 데 실험실에 관심이 있기 때문입니다. 원본 스크립트는 Linux 서버에서 사용하기 위해 작성되었지만 Linux에서 Windows 서버로 전환했습니다.내 플랫 파일 텍스트 파일의 경로가 잘못 되었습니까? Linux에서 Windows 서버로 이동
오류 메시지를 볼 수있는 관리자 권한이없는 서버는 ActivePerl이 설치된 Windows 서버입니다. Perl 스크립트에 정보를 쓸 위치를 알려주는 Windows 해당 경로를 찾는 데 어려움을 겪고 있습니다. 관리자와 통화하는 것에서부터 인트라넷이 E:
드라이브에 매핑 된 것으로 보이지만 치명적인 오류는 아닙니다.
내가 데이터 후 브라우저에서이 스크립트를 실행하려고
폼에 입력 한 그냥 일반적인 반환 :CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
모든 팁, 문서, 자습서는 감사합니다. 고맙습니다.
#!C:\perl\bin\perl.exe -w -t
# Good programming practice dictates...
use strict;
use warnings;
# CGI.pm -- makes life easy
#Carp qw(fatalsToBrowser); outputs the error messages to the browser since there is no terminal to output error messages to. Should be removed before script is used in production.
use CGI::Carp qw(fatalsToBrowser) or die "Problems loading CGI.pm";
# Initialize the CGI Interface
my($cgi) = new CGI;
# Print the Header
print $cgi->header();
#The dbmopen call is now de-appreciated. IE: it no longer works
#Kept for archival reasons
#if (! dbmopen(%DB, "/vol/research/docs/old_site_files/eyesignup/data/eyesignup_NEW.dat", 0666))
# {
# print "Error -- Cannot open database.\n";
# exit;
# }
# Tie is the correct way to do it now. But first we are going to experiment with writing to a flat .txt file.
open (Datastore, '>>',"E:/intranet/sds/research/docs/data.txt") or die "Can't open file: $!";
# Store variables and increment access count for this user
# So param('VARIABLE') is the name of the variables used in the HTML form while $custVARIABLE is the input for the database
my($custFirst) = $cgi->param('firstname');
my($custLast) = $cgi->param('lastname');
my($custGender) = $cgi->param('gender');
my($custAge) = $cgi->param('age');
my($custDiv) = $cgi->param('division');
my($custPhone) = $cgi->param('phone');
my($custEmail) = $cgi->param('email');
my($custEmployee) = $cgi->param('employee');
my($custInternet) = $cgi->param('internet');
my($custwww) = $cgi->param('www');
my($custDemographic) = $cgi->param('demographic');
my($custProjects) = $cgi->param('projectsworked');
my($custExperience) = $cgi->param('experience');
my($custWeekdays) = $cgi->param('Weekdays');
#Kept for archival reasons
#my($custName) = $cgi->param('name');
#my($custGender) = $cgi->param('gender');
#my($custDiv) = $cgi->param('division');
#my($custPhone) = $cgi->param('phone');
#my($custEmail) = $cgi->param('email');
#my($custInternet) = $cgi->param('internet');
#my($custwww) = $cgi->param('www');
#my($custDemographic) = $cgi->param('demographic');
#my($custExperience) = $cgi->param('experience');
#my($custTimes) = $cgi->param('times');
#my($custStudies) = $cgi->param('studies');
#$custTimes =~ s/\r\n/~/g;
#This takes the input and places it into an array, starting with the individual's
@InfoDB = $custFirst."|".$custLast."|".$custGender."|".$custAge."|".$custDiv."|".$custPhone."|".$custEmail."|".$custEmployee."|".$custInternet."|".$custwww."|".$custDemographic."|".$custProjects."|".$custExperience."|".$custWeekdays;
print Datastore (@InfoDB);
print "\n";
#Kept for archivival reasons.
#$DB{$custName} = $custGender."|".$custDiv."|".$custPhone."|".$custEmail."|".$custInternet."|".$custwww."|".$custDemographic."|".$custExperience."|".$custTimes."|".$custStudies;
#Kept for archival reasons. dbmclose is de-appreciated
#dbmclose(%DB);
#Instead use untie. But first we're just going experiment with using a flat storage system.
#untie(%DB);
close (Datastore) or die;
#Now inform the person their data has been saved. This is terribly ancient code so I haven't gotten around to fixing this part yet.
print "Content-type: text/html\n\n";
print "<HTML>
<HEAD>
<TITLE>Thank you!</TITLE>
</HEAD>
<BODY>";
print "<H1><U>Thank You ".$custFirst."\!</U></H1>
<P>We appreciate your assistance.</P>
<HR width=\"75%\">";
print "<P><H3>The following information has been recorded:</H3>
Name: <I>".$custFirst."</I></p><P>
Gender: <i>".$custGender."</i></p><p>
Division: <i>".$custDiv."</i></p><p>
Phone: <i>".$custPhone."</i></p><p>
Email: <i>".$custEmail."</I></p><P>
How often do you use the internet?: <i>".$custInternet."</i></p><p>
How often do you visit the website?: <i>".$custwww."</i></p><p>
Are you familiar with demographic data?: <i>".$custDemographic."</i></p><p>
Do you have work experience in economics, business, or a related field?: <i>".$custExperience."</i></p><p>
Weekdays that you are available: <i>".$custWeekdays."</i></p><p>
";
print "
</BODY>
</HTML>";
나는 내가하고 있어요 한계의 일부를 보상 할 수있는 몇 가지 변경을했습니다. 나는이 작업을 얻을 때까지 예를 들어, 일시적으로 브라우저에 오류를 출력한다. 그리고 이전의 dbmopen
호출 (더 이상 작동하지 않음)에서 플랫 파일 저장소로 이동하십시오.
감사합니다. Strawberry Perl의 휴대용 버전을 사용하여 스크립트를 테스트합니다. 설치에 관리자 권한이 필요하지 않으므로 괜찮을 것입니다. 내가 이런 일을 한 적이 한 번도 없었기 때문에 내 상황이 조금 이상했다. (따라서 제한된 능력과 오류 로그와 같은 것들에 대한 접근). 그것은 내가 추가 업무 책임으로 일하도록 자신을 왜곡해야하는 것 중 하나 일뿐입니다. 감사! – OneBigNewbie