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

As per suggestion from Corion, what happens when you run this?

The HTTP return code is not available for get() without using the LWP::UserAgent OO interface, but this 3 lines of code should ensure that your Windows box is actually getting something (runs on my XP Perl 5.10.1). If this prints something, then it comes down to probable file naming or permission errors in your getstore() statement.

It is hard for me to understand how a new file could be created with no content if the RC is 'OK'. That would imply that you do have the permission to create the file in the first place and therefore have permission to write to it!
Testing Note: delete your "blank" output file between runs to make sure that it is actually being created and not an artifact of some previous run.

Anyway run this simple test and report back.

#!/usr/bin/perl -w use strict; use LWP::Simple; my $content = get("http://perlmonks.org/?node_id=957704"); die "blank content" unless defined $content; print $content;

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

    Nothing is printed when I run the test above. I do notice that there is a very slight lag before it goes back to the command prompt. Anything else I should try?

      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";

        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.