I have a URL like this:
I have to connect to this URL and download the data. Sometimes there will be problem in that particular site. So I have to reconnect and then again download the data.
Here is the code to connect online.
#!/usr/bin/perl use CGI; use LWP; use DBI; use CGI qw(:standard); use LWP::UserAgent; $fetch="http://www.somesite.com"; $ua=new LWP::UserAgent; $res=$ua->get($fetch); $result=$res->content; print "<br>$result<br>";
How can i write a program such that if a data can't be downloaded at first time suppose if any problem persists how can i reconnect to that perticular site and download the data ?
If it can try connecting 5 times and downloading the data and if 5th time also it fails then the program should stop try connecting automatically.
How can i do this?