preface 
 
  Look_up Engine  
 
  email how to  
 
  counter  
 
  regex  
 
  search engine  
 
  home  
 
  ask us  
 

 

Perl scripting


Applications


OO Perl


Perl & Databases


Search a word:
   



© The scientific sentence. 2010

Perl engine almutur
Search a word:
   

Source code:
------------
<title>Perl engine </title>
<table>
<tr>
<td align=center>
<B><font size="2" face="Bookman old style" color="blue">Search 
a word:</font><B></td></tr><tr>
<td align=center>
<form method="get" action="index.php">
<input type="text" name="The_query" size="20"/></td>
<td><input type="hidden" name="key" value = "The_key" 
size="20"/></td>
</tr>
<tr>

<td align=center>
<input type="submit" value = "Find"/>    
<input type="reset"/>
</td>
</tr>
</form>
</td>	
</tr>
</table>



If key == The_key, index.php will send 
The_query to The_engine.cgi.


#--------------------
# File The_engine.cgi
#---------------------
#!/usr/bin/perl
use strict;
use File::Find;

use CGI qw(:standard);
use CGI qw(param);


BEGIN {
    # The path of the related module goes here ..
}

my $search_url = 'The hole path to/index.php';
my $query = param("request");


sub start_of_html()
{
print "Content-Type: text/html; charset=charset\n\n";
print <<END_HTML;
<head>
<title>The results of the search</title>
</head>
<body>

<center><table width="450" border="0" cellpadding="0"  
cellspacing="0" bgcolor="#c5e6ef">
<tr> 
<td height="15" valign="top" bgcolor="#00CCCC">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif"  
color="#ffffff">
<h3><b>Your searched words:</b>       
$query<h3></font></td>
</tr>
</table></center>
<br />

<center><table width="450" border="0" cellpadding="8"  cellspacing="0">
<tr> 
<td width="341" height="23" valign="top"  bgcolor="9b72cf">
<font face="Verdana,  Arial, Helvetica, sans-serif" color="#990000"  
size="3"><b>
<font face="Geneva, Arial, Helvetica,  san-serif" color="#ffffff">
Results of Search:
</font></b></font>
</td>
</tr>
</table></center>

<center><table width="450" border="0" cellpadding="8"  
cellspacing="0">
<tr> 
<td valign="top" height="99" bgcolor="#f1f1fd">
END_HTML
}

my $counting ;
sub subroutine1($query)
{
return if($_ =~ /^\./);
return unless($_ =~ /\.html/i);
stat $File::Find::name;
return if -d;
return unless -r;

open(FILE, "< $File::Find::name") or return;
my $string = <FILE>;
close (FILE);

return unless ($string =~ /\Q$query\E/i);
my $page_title = $_;


if($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;	 
$counting++;
my $links = substr ("$File::Find::name", -20, 15); 
my $parts = "./";
my $part_file = substr ($_, -20, 15); 
my $address =$parts."index.php?key=yes&Integer=".$part_file;
print qq"<li><a href=\"$address\">$page_title</a></b></li>\n";

}
}

sub count
{
if(($counting == 0) && ($query ne '')){
print "<b>There are no maching files .. </b>";
}
}

  

sub end_of_html (){
print <<END_HTML;
</td>
</tr> 
<center></table>
<BR><center>
<hr width = 55%>
</center>
<BR>

</body>
</html>
END_HTML
}


start_of_html();
&subroutine1;	
if ($query){
find(\&subroutine1,  "./");
}
elsif ($query == ''){
print "<b>No words have been entered .</b>";
}
&count;
 
end_of_html();
  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2007. All rights reserved.