dannoura has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm trying to use the module WWW::Search to search this site, with the backend WWW::Search::PubMed. CPAN keeps installing it in C:\Perl\site\lib when it should be in C:\Perl\site\lib\WWW\Search. When I try to run the code:

#! c:\perl\bin use WWW::Search; $query = "lung cancer treatment"; $search = new WWW::Search('PubMed'); $search->native_query(WWW::Search::escape_query($query)); $search->maximum_to_retrieve(100); my $response = $search->response(); if ($response->is_success) { print "Page returned ok"; } else { print "error: " . $response->as_string(); } while (my $result = $search->next_result()) { $url = $result->url; $title = $result->title; $desc = $result->description; print "$result\n"; print "<a href=$url>$title<br>$desc<p>\n";

I get:

Unknown search engine backend PubMed (Can't locate WWW/Search/PubMed.p +m in @INC (@INC contains: C:/Perl//lib C:/Perl/site/lib .) at (eval 5 +) line 2. BEGIN failed--compilation aborted at (eval 5) line 2. ) at C:\Perl\progs\test2.pl line 6

So I tried moving it into C:\Perl\site\lib\WWW\Search. The above script then works but gives no response other than:

Page returned ok

I'm able to search the web via WWW::Search::AltaVista so I know that the WWW::Search module installation is ok. I'm thinking this might be some sort of installation problem. Is there any way to force installation of WWW::Search::PubMed into C:\Perl\site\lib\WWW\Search? Or maybe this is some other problem?

Replies are listed 'Best First'.
Re: problem with module installation
by ant9000 (Monk) on Jul 04, 2003 at 13:05 UTC
    Perl complains about not finding WWW/Search/PubMed.pm in its @INC, so moving the module where you put it should be enough to let it work.
    There are few debug options in WWW::Search, nonetheless: first of all, try
    use WWW::Search; print sort &WWW::Search::installed_engines();
    (more or less pasted from perldoc WWW::Search) to see if PubMed is recognized correctly. Assuming it is, you could try
    use WWW::Search; my $oSearch=WWW::Search->new('PubMed'); $oSearch->native_query( "lung cancer treatment", { search_debug=>1, search_parser_debug=>1 } ); #... whatever ...
    so that the engine will spit out some (hopefully useful) debug information.
    HTH!