OK, tutorial time. Here's the code on the WWW::Search page.
my $sQuery = 'Columbus Ohio sushi restaurant';
my $oSearch = new WWW::Search('AltaVista');
$oSearch->native_query(WWW::Search::escape_query($sQuery));
$oSearch->login($sUser, $sPassword);
while (my $oResult = $oSearch->next_result())
{
print $oResult->url, "\n";
} # while
$oSearch->logout;
The second line, the one that contains the new call is what I call a constructor. It should either return an object (and thus $oSearch will be defined) or undef if Something Bad Happened.
That's the first check. Run the perl debugger, go past that line, then dump the value of $oSearch and see if it's undef or a real object. If it's undef then Something Bad Has Happened and you need to check that your network connection is working, or see if there are any other problems connecting to the Internet.
If it reports that things are good, then we move on to the results .. as you step through the loop, you should see some stuff get returned. Or, perhaps nothing will be returned because there's nothnig to be found.
I can't make it any simpler than that. If this makes no sense to you, then perhaps (and I mean this is the nicest possible way) Perl is not the language for you.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
|