in reply to Re^5: WWW-Search module that works
in thread WWW-Search module that works

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^7: WWW-Search module that works
by talexb (Chancellor) on Jun 14, 2007 at 02:55 UTC

    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

      While I read through the perl debug manual, can you clarify the above code works for you as it is? do you get printed results on new lines, for the search "Columbus Ohio sushi restaurant" ?
          While I read through the perl debug manual, can you clarify the above code works for you as it is?

        I cannot confirm the code works for me, because I don't have that module installed. But I don't *have* to have that module installed to be able to explain to you how to get started, using code from the module's own POS.

        Perlmonks is all about helping someone reasonably computer literate get through some of the bumpier parts of the language and/or the community, assuming a decent amount of effort on the part of the initiate.

        This is by now my fourth reply to your original query, and I've spent some time trying to help you. All you need to do is put the code into a script, run it with perl -d yourScriptHere.pl, step through a few lines (n for next), and dump the value of some variables (x $yourVariable), and, based on those results, move forward with your learning.

        Or someone else will pick up this particular falling torch ..

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds