ch13l01.txt

来自「《Web编程专家指南》」· 文本 代码 · 共 41 行

TXT
41
字号
Listing 13.1 Clone a file.Cloner.CGI#!/usr/local/bin/perl# An example program to clone a file, but which allows for special# processing of lines that include a tag of the form [SPECIAL_TAG]# HTTP usage <A HREF="cloner.pl?fileNameXuniqueID">Link text</A>#Split the argument line and set the unique ID and file to be cloned@args = split('X', $ARGV[0], 2);$uniqueID = $args[1];$cloneDir = '/htdocs/exampleClonerDir/';$cloneFile = $cloneDir.$args[0];#Output the header - note double line feedprint("Content-type: text/html\n\n");#If the file can't be opened, output a terse error messageopen(CloneFile, $cloneFile) ||   die $cloneFile." Can't find requested file\n";#Cloning loop$line = <CloneFile>;while($line = <CloneFile>){    $_ = $line;    if (m/\[SPECIAL_TAG\]/ == 1){        #If the current line has a tag of the form         #[SPECIAL_TAG], do special processing.    }else{        #Since there was no [SPECIAL_TAG], just        #print the line        printf("%s", $line);    }    if(eof(CloneFile)){        close(<CloneFile>);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?