#! /usr/bin/perl -w

push @INC, "/home/liam/packages/basex/Perl";

require BaseXClient;
# use Time::HiRes;
use warnings;
use strict;

my $Port = 9999;

eval {
  # create session
  # default port 1984
  my $session = Session->new("localhost", $port, "admin", "secret");

  $session->execute("open rdf");

  # create query instance
  my $input = "//query with syntax errors";

  my $query = $session->query($input);

  # initialize query
  # fails in 7.0 and later:
  # print $query->init();

  # loop through all results? or chunks of data?
  while ($query->more()) {
      print $query->next();
  }

  # close query
  $query->close();

  # close session
  $session->close();
};

if ($@) {
    print $@;
    exit 1;
}

exit 0;
