Hi,
I am attempting to write a script that will periodically retrieve the
contents of an HTML file using the LWP::Simple module. I am using the
getprint() function, but I have found that sometimes when a web page is
unavailable, I end up with an empty file. What I would prefer to do is
somehow check to see if the HTML file is retrievable and if it is retrieve
it; otherwise, I want to keep the existing file that I have. Basically, I
only want to replace the file if the HTML file is retrievable.
I have tried using the HTTP::Status module, but even when the is_success
function returns true, I sometimes get an empty file using getprint. I
would appreciate any help. I am including the code snippet in its simplest
form to show an example of what I am trying to do.
use LWP::Simple;
my $file = "/path/to/some/file";
my $bakfile;
my $url = "http://www.domain.com/somefile.html";
rename($file,$bakfile); # maintain a copy of the original
open(RETRIEVE, ">$files") || die "Could not open file $file for
retrieval\n";
select(RETRIEVE);
getprint($url);
close(RETRIEVE);
Thanks,
---------------------------
Scott Cornette
Team Leader
InfiNet Product Development
[EMAIL PROTECTED]
757.624.2689 - Voice
757.328.8085 - Mobile
757.625.2473 - Fax
---------------------------
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web