Perl Learning Notes

Source: Internet
Author: User

1) Perl is very flexible, and some people say that the worst thing about reading Perl code is that a judgment condition can be placed behind a statement, for example:

My $value = "value" if $needvalue;
Sometimes, if the preceding statement is long and then the IF statement is placed so short, if you do not look at the following if statement, you may understand the error, which sometimes makes the code a headache.

2) Recently heard a senior said, it is best not to use unless, because for those who have not learned Perl, this may not be easy to understand, try to use Perl has some of the programming language to compare common if, so that anyone looking at the code is more useful, okay, Remember that there are several unless in my code, so let them stay there.

3) Just write Perl, for Perl is only used, not flexible use, remember, once, I used Perl to get the results of shell execution:

My $ret = ' Ls-al | awk ' nr==2 ' | awk ' {print $} ';

See the error, this is not get the desired result, ' is not and ' very similar, but the problem is, I want to get the 2nd row 3rd column results, but I just got 2nd line, which makes me depressed for a while, Clearly in the shell is possible, but how to call in Perl is not? Brother's character is too bad ... So, to test the pipeline there is no problem, no--by, then magic, finally, in the day, read the other predecessors write code,

My $str = "ssh root\@ $ip";

only to find that the original less a "\", Perl directly to the deal as a variable processing, is wayward, do not think ' can also and ' in the same wayward.

Perl Learning Notes

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.