Execute a too long Perl script step by step using cyclic control

Source: Internet
Author: User
Tags perl script
Recently, I was writing a long Perl script to automate the process and steps for task execution. However, there are some easy-to-error steps, such as my VPN is not enabled or the XX service is not started, so some operations cannot be executed, resulting in script running errors.
At this time, I had to fix the configuration error and re-execute the script from the beginning. This wastes a lot of time and makes me very annoyed. I didn't have much fun at work, but where can I remember so many trivial things?
Today, I wrote a circular Control item that can stop at the wrong step and wait for me to modify the wrong step (system environment rather CodeItself), and can start from the stop. The sample code is as follows:
Use warnings; use strict;
Sub test1 {print "test1 \ n ";}
Sub Test2 {print "Test2 \ n ";}
Sub test3 {print "test3 \ n ";
}
My $ result = UNDEF;
Sub controller {my $ code_array = shift; my ($ code, $ code_name) = @ $ code_array; while (1) {my $ new_result = eval {& $ code }; if ($ @) {print "$ @ \ n someting is wrong when execute $ code_name, please input enter [...]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.