I have a Perl code which goes to particular website and extracts the required data from it. I face a problem if I lose my connection: the script stops functioning. How could I make the Perl script resume the connection and start the process from where the interruption took place? Can I use the Perl to resume the connection if so could any one guide me with the steps please.
3 Answers
It is not possible to do this. Once a transport-level network (e.g. TCP/IP) connection is broken you cannot get it back again. And the HTTP protocol does not provide a higher level way of doing this.
You have to open a new HTTP connection to the server and restart your extraction. Whether you have to restart from the beginning, or can resume close to where you were when the connection broke depends on what it is you are fetching, how the website presents it, and the client-side tool you are using to do the fetching.

- 698,415
- 94
- 811
- 1,216
What do you mean when you say "lose my connection" and "goes to a website and extracts data"? Is your perl code managing the Socket Connection and the data scraping itself or are you using a higher level Perl library like LWP or WWW::Mechanize to "extract data"
If the latter then you might like to read this question and the answers

- 1
- 1

- 3,544
- 3
- 31
- 43