CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Problem in getting contents of a url

 



Rehan
New User

Jun 17, 2013, 11:46 AM

Post #1 of 3 (714 views)
Problem in getting contents of a url Can't Post

#!/usr/bin/perl -w
use strict;
use warnings;

use LWP::Simple;

my $webPage = get "zameen.com";

print $webPage;


ERROR: Use of uninitialized value $webPage in print at h1.pl line 9.

Quote

Code
How to remove this error? 


FishMonger
Veteran / Moderator

Jun 17, 2013, 2:40 PM

Post #2 of 3 (708 views)
Re: [Rehan] Problem in getting contents of a url [In reply to] Can't Post

You need to specify the URL, which includes the scheme.


Code
my $webPage = get("http://zameen.com");



Laurent_R
Veteran / Moderator

Jun 17, 2013, 2:49 PM

Post #3 of 3 (707 views)
Re: [Rehan] Problem in getting contents of a url [In reply to] Can't Post

I am not using this module, but do you really expect:


Code
my $webPage = get "zameen.com";


to get the content of an URL? Does "zameen.com" look like an URL in your view?

You probably need, at the very least, something like:


Code
my $webPage = get "http://www.zameen.com";


To start with, I would suggest that you test the get return code. I am fairly sure that it is "undef" in your case.

So change it to something like:


Code
my $webPage = get "http://www.zameen.com" or die "Could not open the URL \n";


It might still not work, but at least you might get a diagnosis telling you where to look.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives