This article mainly introduces Perl delete leading and trailing blanks (remove left and right spaces, white space characters), this article gives a number of methods to achieve this requirement, the need for friends can refer to the following
In
1 Line PerlPerl, for today, has only one line of Perl programs.Perl is famous in a variety of programming languages, such as I, who often write Perl programs that I can't read.For example, the program in this document, although short, estimated one
The Perl script batchreplace.pl can be used to bulk replace the text/code in the file. You can find files of the specified type in the specified directory and recursively check subdirectories, and copy the directory structure of the input file when
Using serial communication, use the following script at the standby to detect heartbeat signal from the host, once the number of not accepted more than the specified number, the standby machine think the host down machine, automatically set as the
These days I looked at Perl's event programming framework Anyevent, focusing on a few articles:
http://search.cpan.org/~mlehmann/AnyEvent-7.05/lib/AnyEvent.pm
Http://search.cpan.org/~mlehmann/AnyEvent-7.05/lib/AnyEvent/Intro.pod
Hello WorldA simple Hello World example:
Copy Code code as follows:
#!/usr/bin/env Perl
Use strict;
Use warnings;
Use Cgi::fast;
while (my $q = new Cgi::fast)
{
Print $q->header ("Text/plain");
print "Hello World";
}
1. Statement BLOCK:The section between {} is block statement blocks.
2. Conditional statement:if (expression) block;
if (expression)BLOCK1else BLOCK2;
if (expression1)BLOCK1;elsif (expression2)BLOCK2;ElseBLOCK3;
#倒置的if语句Expression if
1 All numbers in Perl have the same internal format, only double-precision floating-point numbers (there is no integer value inside perl).
2 Perl allows the use of underscores to delimit longer integers, such as 612980400283768 and 612_980_400_283_76
"." to match wildcard characters for any one character, except for "\ n" line breaks
"*" is used to match previous entries 0 or more times
"+" is used to match previous entries appearing more than once
"?" to match one or more occurrences of the
One, arithmetic operators: + (plus),-(minus), * (multiply),/(except), * * (UP),% (remainder),-(Monocular negative)
(1) The base of the exponentiation can not be negative, such as ( -5) * * 2.5 # error;(2) The result of a exponentiation cannot exceed
Source:Use of the map function of Perl:GrammarMap EXPR, LIST of which there is,Map BLOCK LIST None of this,Define and useExecutes expr or block on each element in the list, returning a new list. For each of these iterations, the values of the
The hash data structure in Perl.A hash is a data structure that consists of a pair of keys-values pairs.These keys and values are arbitrary scalars, but the keys are always converted to strings and must be unique strings.Access to the hash element, $
1. arrays and hash variables in parameters:
When defining the parameter list, there are two ways to define an array or hash variable as the input parameter:
1. Add the Backslash "/" before the type name of the array or hash variable.
2. Place
Use Perl socket
To use the Perl Socket API, you must first load the socket module.Use SOCKET;========================================================== ====================================Socket (file handle, af_inet, data type, protocol
There are five variables in Perl:
Scalar, pointer, array, hash and handle.
1. scalar
Let's take a look at scalar. scalar is the simplest data type in Perl. Variables of this data type can be numbers, strings, floating-point numbers, and are not
Finally, we can get this masterpiece. I did not hesitate to purchase this little camel book online because I had switched to the second version. But when I first got it, I always wondered if I had made a wrong book. Because the first chapter of the
The <> operators in perl can be used as follows:
1) if the angle bracket contains a file handle, the angle bracket operator allows you to read the file handle, such as .2) If the angle brackets are in the search mode, the angle brackets operator
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