box-o-sand/web/html/cgi-bin/query.cgi

36 lines
604 B
Plaintext
Raw Normal View History

2011-01-03 22:32:50 +00:00
#!/usr/bin/env perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(carpout fatalsToBrowser);
BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/home/me/tmp/mycgi-log") or
die("Unable to open mycgi-log: $!\n");
carpout(*LOG);
}
2011-01-03 22:32:50 +00:00
sub main {
my $query = CGI->new();
print $query->header(-content_type => 'text/plain');
2011-01-03 22:32:50 +00:00
my $search = $query->param('q');
2011-01-03 22:32:50 +00:00
if (!$search eq undef) {
printf("You searched for: %s\n", $query->escapeHTML($search));
} else {
printf("Invalid search? You must provide a 'q' argument.\n");
}
2011-01-03 22:32:50 +00:00
}
main();
1;
2011-01-03 22:32:50 +00:00
__END__