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

📄 00000066.htm

📁 一份很好的linux入门资料
💻 HTM
📖 第 1 页 / 共 2 页
字号:
going to change the output of our search in any way. 
&nbsp;<BR>
&nbsp;<BR>$query&nbsp;=~&nbsp;s/([-+i.&lt;&gt;&amp;|^%=])/\\\1/g;
&nbsp;<BR>
&nbsp;<BR>Boy&nbsp;does&nbsp;that&nbsp;look&nbsp;messy!&nbsp;That&nbsp;is&nbsp;basically&nbsp;just&nbsp;a&nbsp;Regular&nbsp;Expression&nbsp;to&nbsp;&nbsp;<BR>escape&nbsp;all&nbsp;of&nbsp;the&nbsp;meta&nbsp;characters.&nbsp;Basically&nbsp;this&nbsp;will
&nbsp;<BR>change&nbsp;a&nbsp;+&nbsp;into&nbsp;a&nbsp;\+.&nbsp;
&nbsp;<BR>
&nbsp;<BR>Now&nbsp;we&nbsp;need&nbsp;to&nbsp;move&nbsp;right&nbsp;along&nbsp;and&nbsp;open&nbsp;up&nbsp;our&nbsp;target&nbsp;document.&nbsp;When&nbsp;we&nbsp;do&nbsp;&nbsp;<BR>this,&nbsp;we&nbsp;will&nbsp;need&nbsp;to&nbsp;read&nbsp;the&nbsp;entire&nbsp;file&nbsp;into&nbsp;one
&nbsp;<BR>variable.&nbsp;Then&nbsp;we&nbsp;will&nbsp;work&nbsp;from&nbsp;there.&nbsp;
&nbsp;<BR>
&nbsp;<BR>open&nbsp;(SEARCH,&nbsp;&quot;$doc&quot;);
&nbsp;<BR>undef&nbsp;$/;
&nbsp;<BR>$text&nbsp;=&nbsp;&lt;SEARCH&gt;;
&nbsp;<BR>close&nbsp;(SEARCH);
&nbsp;<BR>
&nbsp;<BR>The&nbsp;only&nbsp;thing&nbsp;you&nbsp;may&nbsp;not&nbsp;be&nbsp;familiar&nbsp;with&nbsp;is&nbsp;the&nbsp;undef&nbsp;$/;&nbsp;statement&nbsp;you&nbsp;&nbsp;<BR>see&nbsp;there.&nbsp;For&nbsp;our&nbsp;search&nbsp;to&nbsp;work&nbsp;correctly,&nbsp;we
&nbsp;<BR>must&nbsp;undefine&nbsp;the&nbsp;Perl&nbsp;variable&nbsp;that&nbsp;separates&nbsp;the&nbsp;lines&nbsp;of&nbsp;our&nbsp;input&nbsp;file.&nbsp;&nbsp;<BR>The&nbsp;reason&nbsp;this&nbsp;is&nbsp;necessary&nbsp;is&nbsp;due&nbsp;to&nbsp;the&nbsp;fact&nbsp;that&nbsp;we
&nbsp;<BR>must&nbsp;read&nbsp;the&nbsp;entire&nbsp;file&nbsp;into&nbsp;one&nbsp;variable.&nbsp;Unless&nbsp;this&nbsp;is&nbsp;undefined,&nbsp;only&nbsp;&nbsp;<BR>one&nbsp;line&nbsp;will&nbsp;be&nbsp;read.&nbsp;
&nbsp;<BR>
&nbsp;<BR>Now&nbsp;we&nbsp;will&nbsp;start&nbsp;the&nbsp;output&nbsp;of&nbsp;the&nbsp;results&nbsp;page.&nbsp;It&nbsp;is&nbsp;good&nbsp;to&nbsp;customize&nbsp;it&nbsp;&nbsp;<BR>and&nbsp;make&nbsp;it&nbsp;appealing&nbsp;somehow&nbsp;to&nbsp;the&nbsp;user.&nbsp;This&nbsp;is&nbsp;free
&nbsp;<BR>form&nbsp;HTML&nbsp;so&nbsp;all&nbsp;you&nbsp;HTML&nbsp;guys,&nbsp;go&nbsp;at&nbsp;it.&nbsp;
&nbsp;<BR>
&nbsp;<BR>Now&nbsp;we&nbsp;will&nbsp;do&nbsp;the&nbsp;real&nbsp;searching&nbsp;job.&nbsp;Here&nbsp;is&nbsp;the&nbsp;meat&nbsp;of&nbsp;our&nbsp;search.&nbsp;You&nbsp;&nbsp;<BR>will&nbsp;notice&nbsp;there&nbsp;are&nbsp;two&nbsp;commented&nbsp;regular
&nbsp;<BR>expressions&nbsp;in&nbsp;the&nbsp;search.&nbsp;If&nbsp;you&nbsp;want&nbsp;to&nbsp;not&nbsp;display&nbsp;any&nbsp;images&nbsp;or&nbsp;show&nbsp;any&nbsp;&nbsp;<BR>links,&nbsp;you&nbsp;should&nbsp;uncomment&nbsp;those&nbsp;lines.&nbsp;
&nbsp;<BR>
&nbsp;<BR>@records&nbsp;=&nbsp;split(/$recdelim/,$text);
&nbsp;<BR>
&nbsp;<BR>We&nbsp;want&nbsp;to&nbsp;split&nbsp;up&nbsp;the&nbsp;file&nbsp;into&nbsp;an&nbsp;array&nbsp;of&nbsp;records.&nbsp;Each&nbsp;record&nbsp;is&nbsp;a&nbsp;valid&nbsp;&nbsp;<BR>search&nbsp;result,&nbsp;but&nbsp;is&nbsp;separate&nbsp;from&nbsp;the&nbsp;rest.&nbsp;This&nbsp;is
&nbsp;<BR>where&nbsp;the&nbsp;record&nbsp;delimiter&nbsp;comes&nbsp;into&nbsp;play.&nbsp;
&nbsp;<BR>
&nbsp;<BR>foreach&nbsp;$record&nbsp;(@records)
&nbsp;<BR>{
&nbsp;<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$record&nbsp;=~&nbsp;s/&lt;a.*&lt;\/a&gt;//ig;&nbsp;#&nbsp;Do&nbsp;not&nbsp;print&nbsp;links&nbsp;inside&nbsp;this
&nbsp;<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doc.
&nbsp;<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$record&nbsp;=~&nbsp;s/&lt;img.*&gt;//ig;&nbsp;#&nbsp;Do&nbsp;not&nbsp;display&nbsp;images&nbsp;inside&nbsp;this
&nbsp;<BR>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doc.
&nbsp;<BR>&nbsp;if&nbsp;(&nbsp;$record&nbsp;=~&nbsp;/$query/i&nbsp;)&nbsp;{
&nbsp;<BR>&nbsp;print&nbsp;$record;
&nbsp;<BR>&nbsp;$matches++;
&nbsp;<BR>&nbsp;}
&nbsp;<BR>}
&nbsp;<BR>
&nbsp;<BR>This&nbsp;basically&nbsp;prints&nbsp;out&nbsp;every&nbsp;$record&nbsp;that&nbsp;matches&nbsp;our&nbsp;search&nbsp;criteria.&nbsp;&nbsp;<BR>Again&nbsp;you&nbsp;can&nbsp;change&nbsp;the&nbsp;number&nbsp;of&nbsp;search&nbsp;criterion
&nbsp;<BR>you&nbsp;use&nbsp;by&nbsp;changing&nbsp;that&nbsp;if&nbsp;statement&nbsp;to&nbsp;something&nbsp;like&nbsp;this.&nbsp;
&nbsp;<BR>
&nbsp;<BR>if&nbsp;(&nbsp;($record&nbsp;=~&nbsp;/$query/i)&nbsp;&amp;&amp;&nbsp;($record&nbsp;=~&nbsp;/$anotheritem/)&nbsp;)&nbsp;{
&nbsp;<BR>
&nbsp;<BR>This&nbsp;will&nbsp;try&nbsp;to&nbsp;match&nbsp;both&nbsp;queries&nbsp;with&nbsp;$record&nbsp;and&nbsp;upon&nbsp;a&nbsp;successful&nbsp;match,&nbsp;&nbsp;<BR>it&nbsp;will&nbsp;dump&nbsp;that&nbsp;$record&nbsp;to&nbsp;our&nbsp;results&nbsp;page.
&nbsp;<BR>Notice&nbsp;how&nbsp;we&nbsp;also&nbsp;increment&nbsp;a&nbsp;variable&nbsp;called&nbsp;$matches&nbsp;every&nbsp;time&nbsp;a&nbsp;match&nbsp;is&nbsp;&nbsp;<BR>made.&nbsp;This&nbsp;is&nbsp;not&nbsp;as&nbsp;much&nbsp;as&nbsp;to&nbsp;tell&nbsp;the&nbsp;user
&nbsp;<BR>how&nbsp;many&nbsp;different&nbsp;records&nbsp;were&nbsp;found,&nbsp;but&nbsp;more&nbsp;of&nbsp;a&nbsp;count&nbsp;to&nbsp;tell&nbsp;us&nbsp;if&nbsp;no&nbsp;&nbsp;<BR>matches&nbsp;were&nbsp;found&nbsp;so&nbsp;we&nbsp;can&nbsp;tell&nbsp;the&nbsp;user&nbsp;that&nbsp;no,
&nbsp;<BR>the&nbsp;system&nbsp;is&nbsp;not&nbsp;down,&nbsp;but&nbsp;in&nbsp;fact&nbsp;we&nbsp;did&nbsp;not&nbsp;match&nbsp;any&nbsp;records&nbsp;based&nbsp;upon&nbsp;&nbsp;<BR>that&nbsp;query.&nbsp;
&nbsp;<BR>
&nbsp;<BR>Now&nbsp;that&nbsp;we&nbsp;are&nbsp;done&nbsp;searching&nbsp;and&nbsp;displaying&nbsp;the&nbsp;results&nbsp;of&nbsp;our&nbsp;search,&nbsp;we&nbsp;&nbsp;<BR>need&nbsp;to&nbsp;do&nbsp;a&nbsp;few&nbsp;administrative&nbsp;actions&nbsp;to&nbsp;ensure
&nbsp;<BR>that&nbsp;we&nbsp;have&nbsp;fully&nbsp;completed&nbsp;our&nbsp;job.&nbsp;
&nbsp;<BR>
&nbsp;<BR>First&nbsp;off,&nbsp;as&nbsp;I&nbsp;was&nbsp;mentioning&nbsp;before,&nbsp;we&nbsp;need&nbsp;to&nbsp;check&nbsp;for&nbsp;zero&nbsp;matches&nbsp;in&nbsp;&nbsp;<BR>our&nbsp;search&nbsp;and&nbsp;let&nbsp;the&nbsp;user&nbsp;know&nbsp;that&nbsp;we&nbsp;could&nbsp;not
&nbsp;<BR>find&nbsp;anything&nbsp;to&nbsp;match&nbsp;his&nbsp;query.&nbsp;
&nbsp;<BR>
&nbsp;<BR>if&nbsp;($matches&nbsp;eq&nbsp;&quot;0&quot;)&nbsp;{
&nbsp;<BR>&nbsp;$query&nbsp;=~&nbsp;s/\\//g;
&nbsp;<BR>
&nbsp;<BR>print&nbsp;&lt;&lt;&nbsp;&quot;End_Again&quot;;
&nbsp;<BR>
&nbsp;<BR>&nbsp;&lt;center&gt;
&nbsp;<BR>&nbsp;&lt;h2&gt;Sorry!&nbsp;&quot;$query&quot;&nbsp;was&nbsp;not&nbsp;found!&lt;/h2&gt;&lt;p&gt;
&nbsp;<BR>&nbsp;&lt;/center&gt;
&nbsp;<BR>End_Again
&nbsp;<BR>}
&nbsp;<BR>
&nbsp;<BR>Notice&nbsp;that&nbsp;lovely&nbsp;Regular&nbsp;Expression.&nbsp;Now&nbsp;that&nbsp;we&nbsp;had&nbsp;to&nbsp;take&nbsp;all&nbsp;of&nbsp;the&nbsp;&nbsp;<BR>trouble&nbsp;to&nbsp;escape&nbsp;those&nbsp;meta&nbsp;characters,&nbsp;we&nbsp;need&nbsp;to
&nbsp;<BR>remove&nbsp;the&nbsp;escape&nbsp;chars.&nbsp;This&nbsp;way&nbsp;when&nbsp;they&nbsp;see&nbsp;that&nbsp;their&nbsp;$query&nbsp;was&nbsp;not&nbsp;&nbsp;<BR>found,&nbsp;they&nbsp;will&nbsp;not&nbsp;look&nbsp;at&nbsp;it&nbsp;and&nbsp;say&nbsp;``But&nbsp;that&nbsp;is
&nbsp;<BR>not&nbsp;what&nbsp;I&nbsp;entered!''&nbsp;Then&nbsp;we&nbsp;want&nbsp;to&nbsp;dump&nbsp;the&nbsp;HTML&nbsp;to&nbsp;disappoint&nbsp;the&nbsp;user.&nbsp;
&nbsp;<BR>
&nbsp;<BR>The&nbsp;only&nbsp;two&nbsp;things&nbsp;left&nbsp;to&nbsp;do&nbsp;is&nbsp;end&nbsp;the&nbsp;HTML&nbsp;document&nbsp;cleanly&nbsp;and&nbsp;allow&nbsp;for&nbsp;&nbsp;<BR>the&nbsp;back&nbsp;link.&nbsp;
&nbsp;<BR>
&nbsp;<BR>if&nbsp;(&nbsp;$backlink&nbsp;ne&nbsp;&quot;&quot;&nbsp;)&nbsp;{
&nbsp;<BR>&nbsp;print&nbsp;&quot;&lt;center&gt;&quot;;
&nbsp;<BR>&nbsp;print&nbsp;&quot;&lt;h3&gt;&lt;a&nbsp;href=\&quot;$backlink\&quot;&gt;Go
&nbsp;<BR>back&lt;/a&gt;&lt;/h3&gt;&quot;;
&nbsp;<BR>&nbsp;print&nbsp;&quot;&lt;/center&gt;&quot;;
&nbsp;<BR>}
&nbsp;<BR>
&nbsp;<BR>print&nbsp;&lt;&lt;&nbsp;&quot;End_Of_Footer&quot;;
&nbsp;<BR>
&nbsp;<BR>&lt;/body&gt;
&nbsp;<BR>&lt;/html&gt;
&nbsp;<BR>
&nbsp;<BR>End_Of_Footer
&nbsp;<BR>
&nbsp;<BR>All&nbsp;done.&nbsp;Now&nbsp;you&nbsp;are&nbsp;happy&nbsp;because&nbsp;the&nbsp;user&nbsp;is&nbsp;happy.&nbsp;Not&nbsp;only&nbsp;have&nbsp;you&nbsp;&nbsp;<BR>streamlined&nbsp;your&nbsp;website&nbsp;by&nbsp;allowing&nbsp;to&nbsp;search&nbsp;a
&nbsp;<BR>single&nbsp;page,&nbsp;but&nbsp;you&nbsp;have&nbsp;increased&nbsp;the&nbsp;user's&nbsp;utility&nbsp;by&nbsp;giving&nbsp;them&nbsp;the&nbsp;&nbsp;<BR>results&nbsp;they&nbsp;want.&nbsp;The&nbsp;only&nbsp;result&nbsp;of&nbsp;this&nbsp;is&nbsp;more&nbsp;hits.&nbsp;By
&nbsp;<BR>helping&nbsp;your&nbsp;user&nbsp;find&nbsp;the&nbsp;information&nbsp;he&nbsp;needs,&nbsp;he&nbsp;will&nbsp;tell&nbsp;his&nbsp;friends&nbsp;&nbsp;<BR>about&nbsp;your&nbsp;site.&nbsp;And&nbsp;his&nbsp;friends&nbsp;will&nbsp;tell&nbsp;their&nbsp;friends&nbsp;and&nbsp;so
&nbsp;<BR>on.&nbsp;Putting&nbsp;the&nbsp;customer&nbsp;first&nbsp;sometimes&nbsp;does&nbsp;work!&nbsp;
&nbsp;<BR>
&nbsp;<BR>&nbsp;<BR>--&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;白马带著她一步步的回到中原。白马已经老了,只能慢慢的走,&nbsp;<BR>但终是能回到中原的。江南有杨柳、桃花,有燕子、金鱼……&nbsp;<BR>汉人中有的是英俊勇武的少年,倜傥潇洒的少年……但这个美&nbsp;<BR>丽的姑娘就像古高昌国人那样固执:&nbsp;<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;「那都是很好很好的,可是我偏不喜欢。」&nbsp;&nbsp;<BR>&nbsp;<BR>※&nbsp;来源:·BBS&nbsp;水木清华站&nbsp;bbs.net.tsinghua.edu.cn·[FROM:&nbsp;202.99.18.67]&nbsp;&nbsp;<BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>

⌨️ 快捷键说明

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