[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Glimpse.pm anyone?



On Tue, May 16, 2000 at 05:28:35PM -0400, Sam Tregar wrote:

| No, I mean calling into glimpse from Perl.  Basically, I'd roll glimpse as
| a library and link it with some interface code to make it callable from
| Perl.  That way instead of doing something like:
| 
|    $results = system('glimpse -C search');

Which probably wouldn't do what you wanted anyways.  Were you thinking
of back-ticks?

Personally, I invoke glimpse like this -

   open G, "-|" or do {
      # keep searches from taking *too* long.
      alarm 300 ;
      exec "glimpse", @args, $search_arg
   } ;

   while (<G>) { ...

I use the -| form of open so I don't have to deal with shell
metacharacters causing problems, and the ability to set an alarm like
this is useful as well.

This bit of code takes a fraction of a second to run.  The glimpse
executable itself runs for several seconds at best and several minutes
at worst (searching huge amounts of data.)  In my case, the fork/exec
overhead is minimal (less than 1%) compared to the resources used by
glimpse itself.

Your mileage may vary, of course.

| You could do something like:
| 
|   $results = Glimpse->search('-C', 'search');
| 
| Or something.  This would avoid the fork/exec penalty of system().

... which for a modern Unix box is pretty small as I've already said.

To do what you're suggesting would require rewriting glimpse (or
perhaps a crippled glimpse that can only work by talking to
glimpseserver) either in perl, or into a shared library that could be
loaded by perl.  Either case could be a lot of work.  Or maybe not :)
 
-- 
Doug McLaren, dougmc@frenzy.com