Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:43:16+00:00 2026-06-11T03:43:16+00:00

I have written a Perl Script which connects to a set of URLs one

  • 0

I have written a Perl Script which connects to a set of URLs one by one. Each time it connects to a URL, it fetches the result and performs some operations on it.

However, there are a few possibilities where an error might occur.

The most important of these which I am trying to address is, availability issue. The Internet connection might stop working in between. So, lets say I have a list of 1000 URLs, the script has gone through 500 of them successfully and then Internet stops working, as a result, the script aborts with an error. I want to control this condition and implement a pause and resume feature here.

A few lines of code to explain:

$mech=WWW::Mechanize->new();
$mech->timeout(10);

$url="http://example.com/index.php?id=";

while(<INPUT>)
{
chomp $_;
$word=$_;
$url=$url.$word;
eval{$mech->get($url);};

if($@)
{
  # Pause the Script once the if condition evaluates to true
}

....

}

There could be several conditions where I would want to pause the script.

So, I understand that I need to pass some kind of signal to the script which would cause it to pause. At the same time, there should be a functionality provided to the end user, who can press “some key combination” to resume the script.

My guess is that, this would involve some OS API Calls.

On Linux, there is a way to suspend a process, by pressing Ctrl+Z key combination.

However, I am not sure how this can be automated in the Perl Script.

Please let me know if you need more details in order to find a solution to this.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:43:18+00:00Added an answer on June 11, 2026 at 3:43 am

    It’s pretty standard to have a process blocked while waiting for a read. While it’s blocked, it won’t receive any CPU time. No OS calls, outside of what Perl normally does, would be needed. So just issue your prompt “Press enter when ready to resume, and read STDIN.

    Blocked-on-IO is standard as a state for an OS’s process tables. Quite recently, I wrote a socket test script in Perl to work as a dummy server. I left in a haste one night and found “Waiting on port 3371…” prompt on my dummy server’s terminal in the morning. It would have stayed like that for weeks.

    So, you can wrap the whole thing in a labeled IO-loop, and instead of die-ing or croaking use loop controls like so:

    BIT_OF_WORK:
    while ( $more_work ) { 
        ALL_GOOD:
        while ( $all_good ) {
           ...
           my $socket = open_socket() or last ALL_GOOD;
           ...
           last BIT_OF_WORK unless ( $more_work = @queue );
           ...
        }
        say 'Detected Network Down. Press Enter to continue';
        my $user_input = <STDIN>;
    }
    say 'Phew, that was a lot of work!';
    

    You might find redo more to your tastes even.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Perl CGI script which fetches an html page from a
I have written a Perl script that performs many one-sample t-tests. I get thousands
The situation I am in is that I have written a perl script which
I have written a Perl script which opens a directory consisting of various files.
I have a perl script written for version 5.6.1 and which has dependencies on
I have written a small script in Perl which I am executing on Windows
I have written a perl script to access a wcf service method which returns
I have written a perl script to send email using the gmail's smtp server:
I have written a Perl script for the following bioinformatics question, but unfortunately there
I have written a Perl script, I just want to give it to every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.