#!/usr/local/bin/perl -w =pod If this text is displayed on your browser then your web server is not configured to run .cgi programs. =cut use strict; use CGI; my $swish_binary = './swish-e'; my $q = CGI->new; print $q->header, header(), $q->start_form, '

', $q->textfield( -name => 'query', -size => 40, -maxlength => 60, ), '   ', $q->submit, '

', $q->end_form; show_results( $q ) if $q->param('query'); print footer(); #============================================ sub show_results { my $q = shift; my $query = $q->param('query') || ''; for ( $query ) { s/^\s+//; s/\s+$//; tr/\0//d; } return unless $query; my $pid; if ( $pid = open( SWISH, '-|' ) ) { my @rows; while () { next unless /^\d/; chomp; my ($rank,$url,$title,$size) = split /::/; my $link = $q->a({ href => $url}, ($title || 'no title') ); push( @rows, $q->td( {align=>'right'}, $rank ) . $q->td( {align=>'left'}, $link ) . $q->td( {align=>'right'}, $size ) ); } if ( @rows ) { print '

Found: ', scalar @rows, (scalar @rows > 1) ? ' hits' : ' hit', '

'; unshift @rows, $q->th(['Rank','Title','Length']); print $q->table({align=>'center'}, $q->Tr( \@rows ) ); } else { print '

Failed to find any results

'; } } else { unless ( defined $pid ) { print "

Failed to Fork: $!

"; return; } exec $swish_binary, '-w', $query, '-d','::'; die "Failed to exec '$swish_binary' Error:$!"; } } sub header { return < SWISH-Enhanced

Swish Logo


SwishE2 Logo

Table of Contents

EOF } sub footer { return <

EOF }