📄 ch13l01.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -