A summary of the Perl Language Primer-2nd Chapter

Source: Internet
Author: User

$what ='steak'; Print " Fred ate $n ${what}s.\n ";

Boolean value

If the number 0 is false, if it is an empty string ' false,

If it is not a number or a string, turn it into a number or string before judging. The string ' 0 ' is also false

Get user input

$line = <STDIN>;

Remove the rightmost line break

$text ="a line \ n"; Chomp ($text); Print $text;

undef value

If the data is quite undef the value is 0, if it is added to the string, it is empty.

Defined function

If you want to determine if a string is undef instead of an empty string, you can use defined. If it is undef, the function returns FALSE. otherwise returns true.

$madonna = <STDIN>; if defined ($madonna)) {    print"This isundef"}

Other

The variables in the single quotation mark are output as they are, and if they are double quotation marks can be nested variables.

Automatic conversion between numbers and strings

"Z". The 5*7 result is "Z". 35 "Z35"

A summary of the Perl Language Primer-2nd Chapter

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.