Introduction to Perl's process management

Source: Internet
Author: User
Tags command line printf regular expression

When you send a command line to the system shell, the shell creates a process to execute the command. The new process becomes a child of the shell, and its execution does not depend on the shell but coordinates with the shell.

Similarly, a Perl program can start a new process.

Using System () and EXEC ()

The easiest way to build a new process is to use the system operator. Such as:

System ("date");

To send the output to the Now_day file, you can:

System ("Date>now_day") | | Die "Cannot establish now_day documents";

Using single quotes

Another way to generate a process is to place the shell command between two single quotes. Such as:

$nowday = "Now Time:". Date

The $nowday value is the connection between "now time:" And the result of the date command. That is: "Now time: Fri Feb 23:49:23 PDT 1998"

Integrated paradigm

To give a comprehensive example, ask to analyze from date input, week West print "Week unfinished, don't too hard", otherwise print "good work". The concise wording is:

if ('date' = ~ / ^ S /) {
Printf "Welcome to Online Academy, don't be too hard";
} Else {
Printf "Good job n"
}

Date's output format the first byte is a week, and in English it is just the week that does not begin with "s", so a regular expression is used to determine whether the first character is s, and the requirement is met.

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.