Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: LWP::Simple Empty File

by Marshall (Canon)
on Mar 04, 2012 at 17:43 UTC ( [id://957793]=note: print w/replies, xml ) Need Help??


in reply to Re^4: LWP::Simple Empty File
in thread LWP::Simple Empty File

Odd. Let's make sure we are talking about the same thing.
Save the program as for example: testLWP.pl
From the command line type: perl testLWP.pl
I am thinking that something is wrong in your Windows Perl environment.
There are some "tricks" about this - related to file associations.
Invoke Perl explicitly in the command line "perl testLWP.pl".

In theory, we should be able to figure out why this code (3 lines) is not running on your machine.
I think something is wrong that is unrelated to LWP.

Forgive me for asking this, but can you run "helloWorld.pl"?

#!/usr/bin/perl -w use strict; print "Hello World!!\n";

Replies are listed 'Best First'.
Re^6: LWP::Simple Empty File
by idlemind (Initiate) on Mar 04, 2012 at 19:26 UTC

    Just ran the hello world code and it worked fine. Thanks for all your help. I do save files as .pl and then invoke "perl file.pl" in the command prompt.

      Well, I am sorry that I couldn't be of more help.
      I am just flabbergasted as to how this code not only fails to get the web page $content on your machine, but winds up with a null string for $content instead of an undef value.
      #!/usr/bin/perl -w use strict; use LWP::Simple; $|=1; #turn off buffering so we see all the lines print "starting...get...\n"; my $content = get("http://perlmonks.org/?node_id=957704"); die "blank content" unless defined $content; print "ending...get...\n"; print $content; print "END of CONTENT\n";
      The above code runs on my machine. This is bizarre.

      I guess now we come down to the very improbable...how did you install LWP::Simple on your Windows machine?

        I want to thank everyone who helped me with this. Marshall particularly. I don't know what the problem was but I just uninstalled the version I had and installed the latest version of Strawberry Perl again. Voila, LWP:Simple is working now. For completeness, I install LWP:Simple by using CPAN and package in the command prompt.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-24 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found