Perl Language Learning 0512

Source: Internet
Author: User
Tags scalar
#!/usr/bin/perl-w
@lines = ' Perdoc-u-fatan2 '; Don't confuse anti-quotes with single quotes
foreach (@lines)
{
s/\w< (^>}+) >/\U$1/g;
Print
#print "Hello, world!\n"
}


Scalar is the simplest data type in Perl.
For most scalars, it is either a number or a sequence of characters.

You can manipulate the scalar with an operator, and the resulting result is usually a scalar. Scalars can be stored in scalar variables,
These locations can also be read from and written to files and devices.

Inside Perl, the numbers are always saved and calculated by the requirement of double-precision floating-point numbers.
That is, there is no integer value inside perl---The integer constants used in the program are converted to the equivalent floating-point values.

Floating Point Direct quantity
Refers to the wording of a number in the Perl source code. The direct amount is not the result of the operation, nor is it the result of the action, it is
Type the data in the program source code directly.

2**3 represents 2 of the 3-time side, with a result of 8

A string is usually made up of alphanumeric letters, numbers, and punctuation marks, which range from 32 to 126 of ASCII encoding.


"Fred" x 3 #得到 "fredfredfred"
"Barney" x (4+1) #得 "Barneybarneybarneybarneybarney"
5 x 4.8 #本质上就是 "5" x 4, so "5555"
The number of repetitions (right operand) is rounded before use (4.8 becomes 4). The number of repetitions is less than 1 o'clock, resulting in a zero length
An empty string.

Operators that operate on numbers (such as multiplication) if you encounter operands of type string, Perl automatically converts the string to
The equivalent decimal floating-point number to perform the operation. The result of "12" * "3" is 36
The non-numeric part of the string is skipped, and "12fred34" * "3" will get 36.

P52

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.