spacer

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

home / experts / xml / column57

Google SVG Search III

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

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

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji

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