Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Providing a hitcounter for Matt's Simple Search

Posted on 1998-08-19
3
Medium Priority
?
266 Views
Last Modified: 2010-08-05
I'm currently using Matt Wright's Simple Search engine (located at http://worldwidemart.com/scripts/search.shtml ) to search my web pages. It is a basic search so it does not give many options. I would like to have a hitcounter that counts the number of hits that the search produces, so an appropriate response page can be produced. I don't think it's too difficult, but I can't do it. As I'm new to Perl,  can you please tell me how and exactly where to place this hit counter? Thanks!
0
Comment
Question by:zgee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Expert Comment

by:evilgreg
ID: 1204407
So you want to be able to show the number of matches produced?

If so, try this:

Right after
sub return_html {

add in:

$matches=0;
foreach $x (keys %include) {
  if ($include{$x} eq 'yes') { $matches++; }
}

Then just use $matches in your output message, such as:
if (!$matches) {
  print "Sorry, no matches found!\n";
}
else {
  printf("I found $matches %s!\n", $matches==1 ? "match" : "matches");
  ## Detail of matches here....
}


0
 
LVL 1

Accepted Solution

by:
evilgreg earned 600 total points
ID: 1204408
So you want to be able to show the number of matches produced?

If so, try this:

Right after
sub return_html {

add in:

$matches=0;
foreach $x (keys %include) {
  if ($include{$x} eq 'yes') { $matches++; }
}

Then just use $matches in your output message, such as:
if (!$matches) {
  print "Sorry, no matches found!\n";
}
else {
  printf("I found $matches %s!\n", $matches==1 ? "match" : "matches");
  ## Detail of matches here....
}


0
 
LVL 84

Expert Comment

by:ozo
ID: 1204409
#A simpler way to say
   $matches=0;
   foreach $x (keys %include) {
     if ($include{$x} eq 'yes') { $matches++; }
   }
#is
  $matches=grep{$_ eq 'yes'}values %include;
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question