spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column57

Google SVG Search III

Developer News
ActiveState Debuts Open Source Business Suite
Salesforce Offers Visual App Builder
Codesion Steps Out From CVS's Shadow

Wrapping up our Google API project, we finally convert the Perl script into a CGI and decorate the SVG output with a bit of HTML.

Going CGI

Perl has traditionally been popular for powering dynamic Web sites, not least due to the mighty but easy to use CGI module. A common technique is to use the same script for all requests of our little application, distinguishing between them through parameters:

RequestParameter pParameter q
Start HTML page(none or empty)(none or empty)
Response HTML page(none or empty)[search term]
Response embedded SVGsvg[search term]

In code this looks like:

#!/usr/bin/perl -w
use strict;
use CGI;
...
my $cgi = new CGI;
my $query = $cgi->param('q');
my $part = $cgi->param('p');

if (!defined($query) || $query eq "") {
  # print start HTML page
}
else {
  if (!defined($part) || $part eq "") {
    # print result HTML page
  }
  else {
    # access Google and print SVG results
  }
}

The start page consists of a header with a simple form for entering the search term:

  print <<EOF;
content-type: text/html

<html><head><title>Google SVG Search</title></head>
<body><h1>Google SVG Search</h1>
<form><input type=text name=q><input type=submit value='Google Search'></form>
</body></html>
EOF

Google SVG Search


And here come the results...


Produced by Michael Claßen


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Use Web Caching to Make Your Web Site Faster · Creating an Online Shopping Cart Mechanism in PHP · Log JavaScript Errors Using an AJAX-driven Web Service
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Granular Settings for a Database Level Audit · The Perils of a Web 2.0 Transition on Your Business Processes · Facebook Redesigns Site —Again — Nears 400M Mark

URL: http://www.webreference.com/xml/column57/index.html
Created: Jun 10, 2002
Revised: Jun 10, 2002