Add samples/ directory and trivial render-search.pl server.
authorMike Taylor <mike@indexdata.com>
Fri, 1 Mar 2002 09:21:15 +0000 (09:21 +0000)
committerMike Taylor <mike@indexdata.com>
Fri, 1 Mar 2002 09:21:15 +0000 (09:21 +0000)
samples/render-search.pl [new file with mode: 0755]

diff --git a/samples/render-search.pl b/samples/render-search.pl
new file mode 100755 (executable)
index 0000000..352cce2
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+
+use Net::Z3950::SimpleServer;
+use strict;
+
+my $handler = Net::Z3950::SimpleServer->new(SEARCH => \&search_handler,
+                                           FETCH => \&fetch_handler);
+$handler->launch_server("render-search.pl", @ARGV);
+
+sub search_handler {
+    my($args) = @_;
+    print "got search: ", $args->{RPN}->{query}->render(), "\n";
+}
+
+sub fetch_handler {} # no-op
+
+
+package Net::Z3950::RPN::Term;
+sub render {
+    my $self = shift;
+    return '"' . $self->{term} . '"';
+}
+
+package Net::Z3950::RPN::And;
+sub render {
+    my $self = shift;
+    return '(' . $self->[0]->render() . ' AND ' .
+                 $self->[1]->render() . ')';
+}
+
+package Net::Z3950::RPN::Or;
+sub render {
+    my $self = shift;
+    return '(' . $self->[0]->render() . ' OR ' .
+                 $self->[1]->render() . ')';
+}
+
+package Net::Z3950::RPN::AndNot;
+sub render {
+    my $self = shift;
+    return '(' . $self->[0]->render() . ' ANDNOT ' .
+                 $self->[1]->render() . ')';
+}