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

Hi, I have a question about WWW::Google::PageRank module.
I want to use get() method with variable as a parameter but I always get undef as a result.
This is an example that I found and modified a little bit:
use strict; use warnings; use WWW::Google::PageRank; print "Enter URL:\n"; my $temp = <STDIN>; my $url = "http://".$temp; chomp($url); if (defined($url)) { my $pr = WWW::Google::PageRank->new; print scalar($pr->get($url)), "\n"; } else { print 'Page not specified!'. "\n"; }
I tried entering URL from command line, and putting it into variable ($url = $ARGV[0];) and it works just fine.
I also found an example where multiple urls are read from .txt file and that works too. But when I try to get user input from <STDIN>, get($url) returns undef. I'm new in Perl and I don't know what am I doing wrong here.
Do you have any suggestions? Thanks,
Entoni

Replies are listed 'Best First'.
Re: WWW::Google::PageRank module
by Gangabass (Vicar) on Jun 11, 2009 at 01:39 UTC

    Your script works fine for me. How you test it?

      I work in Eclipse (with Perl plugin) and I just run it there. it says enter URl, I put www.net.hr or something and <enter>. result is always undef.
      I also tried in cmd. I'm on WinXP, could that cause problems?

        The documentation even says:

        If query fails for some reason (google unreachable, url does not begin from 'http://', undefined url passed) it return undef.

        Read the documentation and follow the example in the documentation.

        use WWW::Google::PageRank; my $pr = WWW::Google::PageRank->new; print scalar($pr->get('http://www.yahoo.com/')), "\n";