[Xapian-discuss] Perl Search::Xapian

Peter Karman peter at peknet.com
Tue Jan 28 03:19:02 GMT 2014


On 1/27/14 5:05 PM, Jon Bradley wrote:
> Hi,
>
> Trying to learn Search::Xapian and be better at perl at the same time,
> I'm stuck, at the DB_CREATE_OR_OPEN error.  Perl says this:
>
> ~/dev/sandbox/Xapian-perl$ ./Index1-Xap.pl 100-objects-v1.csv db
> "db" is not exported by the Search::Xapian module
> Can't continue after import errors at ./Index1-Xap.pl line 7.
> BEGIN failed--compilation aborted at ./Index1-Xap.pl line 7.
>
> What I did was try to convert the python example code in to Perl.
> There's probably other errors, but my question is how to I deal with
> the :db DB_CREATE_OR_OPEN in perl?  Been reading a lot and
> my understanding of perl I guess is not the best it seems, any
> help would be great, Thanks.
>
> ----------------snip---------------
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> unless ($#ARGV eq 1) { die "Usage: <cvsfile> <dbpath>\n" };
>
> use Search::Xapian;

use Search::Xapian ':db';

will import the constants.


> use Tie::Handle::CSV;
>
> my $csvfile = $ARGV[0];
> my $dbpath = $ARGV[1];
> my $db = Search::Xapian::WritableDatabase->new(
>          path => $dbpath,
>          mode => "DB_CREATE_OR_OPEN",
>      );


DB_CREATE_OR_OPEN is a constant so it should not be quoted.


-- 
Peter Karman  .  http://peknet.com/  .  peter at peknet.com



More information about the Xapian-discuss mailing list