⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch13.htm

📁 美国Macmillan出版社编写的Perl教程《Perl CGI Web Pages for WINNT》
💻 HTM
📖 第 1 页 / 共 5 页
字号:
	print MAIL "\tTired Eyes/Eat Muff\t\t\t$FORM{x11}\n" if $FORM{xx11};

	print MAIL "\tJism/Blue Fish/Who Are Them?\t\t\t$FORM{xx12}\n"

if $FORM{x12};

	print MAIL "\t Henson's Nuts/Feel Space \t\t\t$FORM{x13}\n" if $FORM{xx13};

	print MAIL "\t Needle Nose/Angry Lemon/BBQ Babies \t\t\t$FORM{xx14}\n" if

$FORM{x14};

	print MAIL "\n\n";

}

</PRE>

</BLOCKQUOTE>

<P>

A sample order delivered to the warehouse might look like:

<BLOCKQUOTE>

<PRE>

--- Forwarded mail from nobody (SVR4 nobody uid)

Date: Tue, 6 Aug 1996 12:35:35 -0700

From: nobody (SVR4 nobody uid)

Subject: Order form

The following is an order form received on the Web.

Requested by:

	Joe Smith

	21 Anywhere Lane

	Ingersoll, Wyoming

	3049112

	515-555-1234

	joes@wyenet.com

Misc Items:

	Hats				1

	Googoo Bag			4

	Record Bag			1

	T-shirt (G on W)		1

	T-shirt (G on B)		1

	T-shirt (B on G)		1

	1xSlipmat			1

	2xSlipmat			1

Albums:

	Petite Fauves/First Bite Vol 1			1

	Ten Days Late/Maiden Voyage EP			1

	Suggestive/Advances				2

	Push Up/Heartbreaker				1

	Petite Fauves/First Bite Vol 3 pt 1			1

	Petite Fauves/First Bite Vol 3 pt 2			1

	Seoul Train/Viper Room EP			1

	Petite Fauves/First Bite Vol 4			1

	Jism/Gravity				1

	Doodle Tool/Eat Muff

	Henson's Nuts/Feel Space

---End of forwarded mail from nobody (SVR4 nobody uid)

</PRE>

</BLOCKQUOTE>

<P>

This e-mail order is sent using the order.pl script, which sends

three copies of the user's data to the correct e-mail addresses.

<H2><A NAME="TheDatabaseSearchExcite"><FONT SIZE=5 COLOR=#FF0000>

The Database Search Excite</FONT></A></H2>

<P>

Going beyond the limits of the Gallery searches, there is also

the freely available excite search engine, which can search a

Web site for specific word(s). Members can use excite to find

every mention of a band or artist in the Goo Goo Records site,

returning a match page like the one shown in Figure 13.11.

<P>

<A HREF="f13-11.gif" tppabs="http://210.32.137.15/ebook/PC%20Magazine%20Programming%20Perl%205.0%20CGI%20Web%20Pages%20for%20Microsoft%20Windows%20NT/f13-11.gif"><B>Figure 13.11:</B> <I>The result of an Excite search</I>.</A>

<P>

The wonderful thing about the excite search engine is that it

is written using a lot of Perl, unlike many other search engines,

so you might be able to&nbsp;learn a trick or two by looking through

some of its coding. This is the aindex.pl script which links the

index for the search engine with the search engine itself, also

known as a wrapper script, so that the two sources of data are

always current. The listing is as follows:

<BLOCKQUOTE>

<PRE>

#!/bin/sh

perl=/usr/local/bin/perl

eval &quot;exec $perl -x $0 $*&quot;

#!perl

## Copyright Architext Software, 1994 (c)

##

## This program is a flexible wrapper for the index program. For

## maximum efficiency, you might want to invoke the executable

## directly, pointing it to the proper info file with &quot;-C&quot;.

## this script will index a collection in a 'safe' directory

## and then move the finished index files in to the specified

## destination location once indexing completes successfully.

## This script will also mail a specified user when indexing completes

## if a email address is given in the collections configuration file

$root = &quot;C:\\ews&quot;;

$ENV{'PATH'} = '/bin:/usr/bin';

unshift(@INC, &quot;$root/perllib&quot;);

require 'architextConf.pl';

require 'os_functions.pl';

require 'ctime.pl';

$database = shift;

if (! $database) {

    $error = &quot;Must specify database&quot; unless $database;

    goto DONE;

}



$logfile = shift;

$progfile = shift;

$errfile = shift;



## create an empty .inv file so that index forms can tell that

## aindex.pl was actually invoked

open(TEMP, &quot;&gt;$root/collections/$database.inv&quot;);

close(TEMP);



## the following code seeds the log files appropriately

$|=1;

if ($errfile) {

    unlink($errfile);

    open(ERRS, &quot;&gt;$errfile&quot;);

    print ERRS &quot;No errors encountered so far...\n&quot;;

    close(ERRS);

}

if ($logfile) {

    unlink($logfile);

    open(LOG, &quot;&gt;$logfile&quot;);

    print LOG &quot;Nothing yet logged to this file.  Check error log for problems.\n&quot;;

    close(LOG);

}

if ($progfile) {

    unlink($progfile);

    open(PROG, &quot;&gt;$progfile&quot;);

    print PROG &quot;Nothing yet logged to this file.  Check error log for problems.\n&quot;;

    close(PROG);

}





$logfile = &quot;-log $logfile&quot; if $logfile;

$progfile = &quot;-prog $progfile&quot; if $progfile;



## Read the configuration file and look for the database.

%attr = &amp;ArchitextConf'readConfig(&quot;$root/Architext.conf&quot;, $database);



if (! $attr{'CollectionInfo'}) {

    $error =  &quot;Configuration file must specify CollectionInfo file\n&quot;;

    goto DONE;

}



##ECO -- improvements to indexing rules 

$filter = $attr{'IndexFilter'}; ## check for html only indexing

$filterflag = &quot; &quot;;

$filterflag = &quot;-html&quot; if ($filter =~ /HTML/);

$filterflag .= &quot; -text&quot; if ($filter =~ /TEXT/);

if ($filter =~ /CUST/) {

    $clusionfile = &quot;$root/collections/$database.excl&quot;;

    unlink($clusionfile);

    &amp;compileExcludeFile($attr{'ExclusionRules'}, $clusionfile);

    goto DONE if $error;

}

$filterflag .= &quot; -excl $clusionfile&quot; if ($filter =~ /CUST/);





$mailid = $attr{'AdminMail'};  ## check for user to alert when finished



## ECO keep back compatibility with old .conf files

if ($filter =~ /Text/) {

    $filterflag = &quot;-html -text&quot; ;

    $filterflag .= &quot; -excl $attr{'ExclusionRules'}&quot; if $attr{'ExclusionRules'};

} 



chop($startTime = &amp;ctime(time));



## Possibly create a CollectionInfo file.

if (! -e $attr{'CollectionInfo'}) {

    print STDERR &quot;Creating CollectionInfo file '$attr{'CollectionInfo'}'\n&quot;;

    $attr{'PidFile'} = &quot;$root/collections/$database.pid&quot;;

    &amp;ArchitextConf'makeInfoFile(%attr);

    if (! -e $attr{'CollectionInfo'}) {

	$error = &quot;Failed to create CollectionInfo file&quot;;

	goto DONE;

    }

}







## calculate $newroot here to do indexing in a 'safe' directory to

## keep index as available as possible

$newroot = $attr{'CollectionRoot'};

$newroot =~ /[\\\/]?([^\/\\]+)$/;

$rootstub = $1;

$newrootdir = $attr{'CollectionIndex'};

$newroot = &quot;$attr{'CollectionIndex'}/new/$rootstub&quot;;

$chmodfiles = &quot;$newroot*&quot;;

$cpfiles = &quot;$newroot*&quot;;

$cpdest = &quot;$newrootdir&quot;;

$rmfiles =  &quot;$newroot*&quot;;

$newroot = &quot;-R $newroot&quot;;



## create 'new' subdirectory for indexing

if (! -e &quot;$attr{'CollectionIndex'}/new&quot;) {

    $exit = &amp;make_directory(&quot;$attr{'CollectionIndex'}/new&quot;);

    $error = &quot;Can't mkdir $attr{'CollectionIndex'}/new -- $!&quot; if $exit;

    goto DONE if $exit;

}



if (-e &quot;$root/collections/$database.cus&quot;) {

    &amp;copy_files(&quot;$root/collections/$database.cus&quot;, 

		&quot;$attr{'CollectionIndex'}/new&quot;);

}

 

## remove error flag from any previous indexing runs

unlink(&quot;$root/collections/$database.err&quot;);



if (! $attr{'CollectionContents'}) {

    $error = &quot;Configuration file must specify CollectionContents\n&quot;;

    goto DONE;

}



if (! $attr{'IndexExecutable'}) {

    $error = &quot;Configuration file must specify IndexExecutable\n&quot;;

    goto DONE;

}





$indexer = &amp;ArchitextConf'makeAbsolutePath($attr{'IndexExecutable'},

					   $attr{'ArchitextRoot'});





if (! &amp;executable($indexer)) {

    $error = &quot;IndexExecutable '$indexer' does not exist or is not really exectuable\n&quot;;

    goto DONE;

}

    



## Pipe stuff into the indexer. Or send it on the command line.

## Args are sent on the command line unless one of the files in

## CollectionContents is a list file.  We assume CollectionContents is

## specified as a set of files separated by colons. If the first

## character of a file name is '+', we assume it points to a list file

## whose contents are read and passed to the indexer as if they were

## specified in CollectionInfo itself.  

## Will pass exclusion argument to executable as well.

$output_file = &quot;$root/collections/$database.out&quot;;

unlink($output_file);

@inputs = split(/[,;\s]+/, $attr{'CollectionContents'});

$index = join(&quot; &quot;, @inputs);

$index = &quot; &quot; . $index;

if ($index =~ /\s\+/) { 

    ## this is the filelist case

    $index =~ s/\+//g;

    $index_command = &quot;$indexer -C $attr{'CollectionInfo'} -flist $index $newroot

	$logfile $progfile &gt; $output_file&quot;;

    $index_command = &amp;convert_file_names($index_command); 

    $exit = system($index_command);

  

} else {

    ## place arguments on command line instead of through filelist

    $index_command = &quot;$indexer -C $attr{'CollectionInfo'} $newroot $index $logfile

	$progfile $filterflag &gt; $output_file&quot;;

    $index_command = &amp;convert_file_names($index_command);

    $exit = system($index_command);	   

}



open(INDEX, $output_file);

##capture errors from output of index process

while ($errline = &lt;INDEX&gt;) {

    next unless ($errline =~ /^ARCHITEXTERROR:/);

    $errline =~ s/^ARCHITEXTERROR://;

    unshift(@errs, $errline);

}



close(INDEX);

unlink($output_file);



## check for error output or error exit status from indexer

if (($#errs &gt; -1) || $exit) {

    $errorflag = 1;

    $error = $! if $exit;

}



&amp;remove_files(&quot;$attr{'CollectionIndex'}/new/*.tmp*&quot;);



if (-e &quot;$root/collections/$database.term&quot;) {

    $error = &quot;Indexing process was terminated by the administrator.&quot;;

    $terminated = 1;

    unlink(&quot;$root/collections/$database.term&quot;);

}



if ($terminated || $error || $errorflag) {

    chop($endTime = &amp;ctime(time));

    goto DONE;

}



## sanity check

if (! -e &quot;$attr{'CollectionIndex'}/new/$database.dat&quot;) {

    $error = &quot;Indexing error -- no .dat file found.&quot; ;

    chop($endTime = &amp;ctime(time));

    goto DONE;

}





## make the index files readwriteable by all to avoid problems

$exit = &amp;make_files_readwriteable($chmodfiles) unless ($error || $errorflag);

## move the now successfully built index files to the official location

$exit = &amp;copy_files($cpfiles, $cpdest) unless ($error || $errorflag);

$error = &

⌨️ 快捷键说明

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