#!/usr/bin/perl -w

$VERSION = '1.5';

=head1 NAME

fzindex - index wrapper around OurNet::FuzzyIndex

=head1 SYNOPSIS

    % fzindex index.db *.txt    # shell glob
    % fzindex index.db '*.txt'  # glob string

=head1 DESCRIPTION

Just run fzindex at command line. The first argument is the db file
to store index results, remaining arguments being glob patterns of
files to be indexed.

=cut

use OurNet::FuzzyIndex '1.5';
use strict;

local $/;

my $db = OurNet::FuzzyIndex->new(
    shift or die "Usage: $0 <indexfile> [files | filespec]\n"
);

foreach my $file (<@ARGV>) {
    next if $db->findkey($file);

    print "indexing $file...\n";

    open _, $file;
    $db->insert($file, <_> || '');
    close _;
}

1;

__END__
