Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Can someone elaborate as to why this isn't working

by coder45 (Initiate)
on Jan 01, 2006 at 12:27 UTC ( [id://520232]=perlquestion: print w/replies, xml ) Need Help??

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

#! Perl\bin\perl -w use WWW::Search; open FILE1, "> url1.txt" or die "$!"; my $oSearch = new WWW::Search('Yahoo::UK'); my $sQuery = WWW::Search::escape_query("world cup 2006"); $oSearch->native_query($sQuery); while ( my $oResult = $oSearch->next_result() ) { print "Adding: ", $oResult->url, "\n"; print FILE1 $oResult->url, "\n";
I am on activeperl 5.8X, it generates the url1.txt file but it is empty

Replies are listed 'Best First'.
Re: Can someone elaborate as to why this isn't working
by tirwhan (Abbot) on Jan 01, 2006 at 12:47 UTC

    Running this exact code (with or without strict and warnings enabled) with perl 5.8.4 on Linux works fine, it returns 10 URLs, both at the command line and in the file (WWW::Search version 2.46).

    You could try using ethereal to view the traffic and see whether something is wrong there, or turn on the search_debug and search_parse_debug options in native_query.


    A computer is a state machine. Threads are for people who can't program state machines. -- Alan Cox
Re: Can someone elaborate as to why this isn't working
by randyk (Parson) on Jan 01, 2006 at 17:14 UTC
    This problem, at least on Win32, seems to be with the (older) available WWW-Search and WWW-Search-Yahoo ppm packages. I just placed the most recent versions of these at http://theoryx5.uwinnipeg.ca/ppms/, which seems to fix this.
      How did you 'replace' them I am a newbie and the option I see seems to install it only, but it says "already installed" for www::search and www;:yahoo

        coder45, taking a quick peek at the ppm commands yields the following results:

        c:\>ppm help Type 'help command' for more detailed help on a command. Commands: describe - describes packages in detail exit - exits the program help - prints this screen, or help on 'command' install - installs packages profiles - manage PPM profiles properties - describes installed packages in detail q - exits the program query - queries installed packages quit - exits the program remove - uninstalls packages repository - adds, removes, or sets repositories s - searches for packages in a repository search - searches for packages in a repository settings - view or set PPM options targets - views or sets target installer backends tree - shows package dependency tree uninstall - uninstalls packages unset - view or set PPM options upgrade - shows availables upgrades for installed packages version - displays the PPM version (3.2) Extra Help Topics: (not commands) ppm_migration - guide for those familiar with PPM prompt - how to interpret the PPM prompt quickstart - a crash course in using PPM unicode - notes about unicode author names

        So you may want to give the following a try:

        c:\>ppm upgrade WWW::Search

        Update: Hmm, that won't help you out because it will query the activeperl repository. To re-install from Randy's repository, try the following:

        c:\>ppm install http://theoryx5.uwinnipeg.ca/ppms/WWW-Search.ppd -forc +e
        Note the -force option which will reinstall the package if you already have it installed.

        -- vek --
Re: Can someone elaborate as to why this isn't working
by serf (Chaplain) on Jan 01, 2006 at 13:22 UTC
    Are you doing a
    close(FILE1);
    after you have finished writing to the file?

    I'm not familiar with activeperl - but is there a chance it's not flushing the output to the file?

    (Although I would *expect* Perl to cleanly flush to and then close the filehandle when the script ends!?)

      serf, good guess but activeperl behaves no differently than Perl on any other box in this regard. The buffer will be flushed and the filehandle closed when the program ends.

      -- vek --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://520232]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found