CGI and Perl

a real world example of WWW::Search.

# Copyright (c) 1996 University of Southern California.
 # All rights reserved.
 use strict;
 &usage if ($#ARGV == -1);
 &usage if ($#ARGV >= 0 && $ARGV[0] eq `-?');
 use WWW::Search;
 use Getopt::Long;
 &GetOptions(\%opts, qw(v a e=s o=s@)); # i.e -v -e=<string> -o=<options>
 &usage if ($#ARGV == -1); # we MUST have one left, the query
 my($verbose) = $opts{`v'};
 my($all) = $opts{`a'};
 &main(join(" ", @ARGV));
 exit 0;
 sub print_result {
   my($result, $count) = @_;
   my($prefix) = "";
   $prefix = "[$count] " if defined($verbose);
   if ($all) {
     foreach ($result->urls()) {
       print "$prefix$_\n";
       $prefix = "      ";
   } else {
     print $prefix, $result->url, "\n";
 sub main {
   my($query) = @_;
   my($count) = "001" if defined($verbose);
   my($search) = new WWW::Search($opts{e});
   if (defined($opts{`o'})) {
     $query_options_ref = {};
     foreach (@{$opts{`o'}}) {
       my($key, $value) = m/^([^=]+)=(.*)$/;
       $query_options_ref->{$key} = WWW::Search::escape_query($value);
   $search->native_query(WWW::Search::escape_query($query), $query_options_ref);
   my($way) = 0; # 0=piecemeal, 1=all at once
   if ($way) { # return all at once.
     foreach $result ($search->results()) {
       print_result($result, $count++);
   } else { # return page by page
     while ($result = $search->next_result()) {
       print_result($result, $count++);

Figure 10.2. Output possible from search.PL.


Adding a search engine to your site with Glimpse greatly increases the usefulness and functionality of your service. Whether you have an online catalog or are just providing information, Glimpse is an easy way to make your information more accessible. The WWW::Search module is a good way to provide a seamless link from your on-site search to information resources elsewhere on the Internet.

Datebooks, Calendars, and Scheduling on the Web

HyperCal--A Modular Perl5 Calendar and Datebook As the Internet and corporate intranets become more and more widespread, and we find Netscape and other browsers running on more and more PCs, Web-based applications that keep us organized are becoming more prevalent. Why use a Web-based calendar or datebook? Web-based calendars and datebooks are the ultimate way to take advantage of the Web, especially in inter-office, or intranet environments.

Let's consider an example. Your boss has given your team a new project. It is your responsibility to coordinate the schedules of each of the 10 people on your team. Do you see where this is going? Each member could access a Web-based scheduling mechanism, update his or her schedule, see what everyone else is doing, easily communicate with each other, make comments, and so on. In addition to being a convenient and efficient way to coordinate people and manage resources, once the data has been entered, you can easily use Perl to generate reports, calculate efficiency of work cycles, and so on. The possibilities are endless. Furthermore, using Perl and the Web, the system is accessible anywhere Netscape is running and is totally extensible and scaleable. You could manage and track the schedules of everyone in your entire organization.

by BrainBellupdated