时间: 2021-07-31 作者:daque
email子进程 #*****************begin body************* print "<h1>thank you for filling out the form</h1>"; $firstname = $value[0]; $lastname = $value[1]; $email = $value[2]; print "your first name is $firstname<br>"; print "your last name is $lastname<br>"; print "your e-mail is $email<br>"; $to = $email; $from = "clinton\@whouse.gov"; $sub = "subject of my first e-mail"; $body = "the form was filled out by $firstname $lastname thank you goes on another line."; &email($to,$from,$sub,$body); #***************end body****************** -------------------------------------------------------------------------------- 在上头的例子中,我在步调的body反面减少了7行。你须要正片那些行到test2.cgi的body中。有两种办法: 在pc上的文本编纂器中举行正片和粘贴,而后用ftp从新上传,这时候不用从新运转chmod。 不妨在unix提醒符下运转emacs或pico,对文献举行窜改,而后生存和退出。 这时候你不妨再试试form。要在testform.htm页面中输出你本人的邮件地方。当你提交这个form时,表露截止与往日一律。但即使你在几秒种后察看你的e-mail,你会看到一封来自president clinton的动静。 让咱们看看那些行: $to = $email; - 正片变量$email中的实质到变量$to中。 $from = "clinton\@whouse.gov"; - 树立变量$form为clinton@whouse.gov。反斜线(\)称为escape character。@标记在perl中有特出意旨,表白一个数组,这时候,即使咱们不想援用数组,而只用@标记自己,须要在前方加一个"\"。 比方,即使我敲入底下这行: $amount = "he owes me $20.00"; 将获得一个缺点,由于perl将试图考察一个称为$20.00的变量。咱们不妨如许写: $amount = "he owes me \$20.00"; $sub = "subject of my first e-mail"; 这行很径直。 $body = "the form was filled out by $firstname $lastname thank you goes on another line."; 这不过一个吩咐 - perl吩咐总以分号中断。归来的字符是赋给$body的字符串中的另一个字符。这很简单,由于不妨敲入引号,而后象在字处置器中一律敲入多行文本,而后用引号中断。结果,象其它语句一律敲入引号。 也不妨象如许而获得沟通的截止: $body = "the form was filled out by $firstname $lastname \n thank you goes on another line."; \n为换行符 - 当双引号中包括\n时,把它翻译成回车符。这对email也起效率 - 它是用ascii,而不是html写的。提防html不留心源代码是在一条龙仍旧在多行。即使想在html中介入一条龙,须要插入一个<br>或<p>标志符。 &email($to,$from,$sub,$body); email子进程在底下的readparse子进程中设置。它被摆设成很好用,只需大略地敲入 &email( addressee , reply-to, subject, message body) 例子中也不妨如许传播参数: &email($email,"clinton\@whouse.gov","subject of my first e-mail","this is line 1 \nthis is line 2"); 然而我觉得辨别赋值对于步调的编纂和观赏更简单。>>