Here are some notes for learning and using Perl. List one item today:1. Analyze the Matching content of the following regular expression
/^/B [/W.] {1, 12}/B $/
Answer: This regular expression matches a line that starts with a character and
Note:Read the output of the "netstat-p tcp" command, extract the data in the foreign address section, and count the multiple connections of the same IP address.
Advantages:Compared with the output of the netstat command, you can more intuitively
Sort Function Sort list Sort Block List Sort subname list The usage of sort is as follows. It sorts the list and returns the sorted list. If the subname or block is ignored, sort is performed in the standard string comparison order (for example,
The client serialization object of Perl memcached adopts the nfreeze method of the storable module, which calls the C extended do_store method. The deserialization uses the thaw method of the storable module, this method is the do_retrieve method of
Example: Assume that/Fred. + Barney/is used for matching on Fred and Barney went bowling last night. We know the regular expression.
Next we will explain this process in detail: first, the sub-mode Fred will match the corresponding string. The next
Search for substrings:
Index () and rindex ()
These two functions are used to find strings in strings. The rindex function is the same as the index function, except that it is located later.There are two main usage options: Index ($ string, $
① File Operations
To read a string from a file using Perl, you can use either of the following methods:1. Read all the content in the file into an array at a time (this method is suitable for small files ):
Code highlighting produced by Actipro
It seems thatCode, Passed the test
# ! /Usr/bin/perl Sub Func1 { Print " Func1 is running \ n " ;} Sub Func_test { My $ Func_ref = Shift ; # Ref will return 'code' if it's function reference If (( Ref ( $ Func_ref ) Eq " Code
Mac OSLowerPerlLinkSQLInstallation of related modules(Notes)
--Based onDBIAndDBD: Sybase
Preface:
This article is a supplement to . It mainly explains how to install Perl DBI and DBD modules in Mac OS.
This article is based on
Generally, Web sites include many services and applications. We cannot know whether the system is running normally in real time, especially when the server goes down or the application goes down at night, will affect the business andDuring user
#! /Usr/bin/perl
Use warnings;
Use strict;
My $ flag = 0;My $;While ()
{If (/^> /){$ Flag = 1;$ A = 0;}If ($ flag){Print $ _;$ A ++;}If ($ A = 3){$ Flag = 0;}}############! /Usr/bin/perl-WUse strict;Open (logout, "> out. log") or die "can't create "
Reason
Looking back at Perl recently, on the one hand, my customer manufacturers developed a lot of things with Perl, on the other hand, they reviewed the Perl language and had some experiences. Record it for your reference.
I am working on a small
Posted on Netease blog 21:22:33
3.1 list Printing
# When reading each list value from stdin, it is processed by chomp. Therefore, each list element is removed from the line break at the end.Chomp (@ lines = );Print "print the list \ n ";Foreach $
1) sort function
Sort listSort Block ListSort subname list
The usage of sort is as follows. It sorts the list and returns the sorted list. If the subname or block is ignored, sort is performed in the standard string comparison order (for example,
Method 1: Use the Switch Package in analyticdb 5.8
Use switch;Switch ($ Val ){Case 1 {print "Number 1 "}Case "A" {print "string "}Case [1 .. 10, 42] {print "number in list "}Case (@ array) {print "number in list "}Case/\ W +/{print "pattern "}Case
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