In Perl, the DBI module is an interface for MySQL database-related operations, and the DBI module needs to be installed in the environment first. The approximate steps for Perl to handle database operations are as follows:#声明使用DBI模块Use
There are two ways in which a Perl program needs to handle user input parameters:The first method is to use the @argv arrayThe second approach is to call the Getopt::long module, which is convenient and powerful. This article mainly introduces this
Occasionally write Perl script, with Eclipse open too slow, NotePad bar, color is too monotonous, notepad++ is undoubtedly not a good choice, but when you want to input Chinese comments, often jam very uncomfortable, and finally choose to use
Server program
Accept client information and send a response#!/usr/bin/perl-w# socket_server.plUse strict;Use Io::socket;Use Io::select;# hash to install IP PortMy ($ser _addr, $ser _port) = ("127.0.0.1", "12345");Our ($buffer, $len);My $socket
I. Introduction
The pattern refers to the character of a specific sequence in the string. The backslash contains:/DEF/That is, the pattern def. Its usage is as follows: Use the function split to divide a string into multiple words in a certain mode:
Reverse connection
Code :
1 .#! /Usr/bin/perl
2. # usage:
3. # nc-VV-l-P port (default 1988) on your local system first, then
4. # Perl $0 remote IP (default 127.0.0.1) remote_port (default 1988)
5. # type 'exit 'to exit or press enter to gain
1. delimiters
= ~ M/there /;
= ~ S/there/here /;
There are also types of delimiters:
= ~ /There/
= ~ M # there #;
= ~ S # there # here #;
= ~ M (there );
= ~ S (there) (here );
= ~ M {there };
= ~ S {there} {here };
= ~ M [there];
= ~ S [there]
The Perl Command Line parameters are stored in the Perl custom variable @ argv by default.# Determine whether the number of parameters is 0. according to the context, here is the = symbol. Here @ argv refers to the number of elements in the command
\ W matches a letter, number, or underline, it is equivalent to [a-zA-Z_0-9] \ s matching an empty character \ D matching a number \ B matching the beginning and end of a word ^, $ is the unit of action to lock the location, while \ B locks the
1. $ position =Index(String, substring, skipchars );
This function returns the position of the substring in the string. If the substring does not exist,-1 is returned. The skipchars parameter is an optional parameter, indicating the number of
Perl is often used to process files in CSV format. Such files are similar to two-dimensional arrays, so operations on two-dimensional arrays are actually performed.For such a row and column table, we often need to sort by a column or by a column
The project needs to send soap messages for some operations. Because the SOAP protocol is built on the HTTP protocol, this problem can also be solved by sending HTTP requests. In addition, the project also needs to consider support for the SSL
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 following is a DNA sequence stored in F: \ perl \ data.txt under the window:
Copy codeThe Code is as follows: aaaaaaaaaaaaaagggggttttcccccccc
CCCCCGTCGTAGTAAAGTATGCAGTAGCVG
Ccccccccggggggggaaaaaaaaaaaaattttttat
AAACG
The following is a
1. Search for existing modulesHttp://search.cpan.org/
2. Input an XML query and select a module that has a high rating and can meet your needs:XML: SimpleUse warnings;Use XML: Simple;Use Data: Dumper;
# Converting XML files into Hash results
Delete an object
Use unlinke functions, such as unlink $ file, unlink $ file1, $ file2, $ file3
Open a file
Open the file with three parameters, which makes it easy to differentiate the mode and file name. This method is supported in Versions later
For example:
Copy codeThe Code is as follows: unless ($ fred = ~ /^ ([A-Z _] \ w * $/I ){
Print "The value of \ $ fred doesn't look like a Perl identifier name. \ n ";
}
Using unless means that either the condition is true or a block of code is
Perl was first designed by Larry Wall), which was published in December 18, 1987. Perl uses the features of C, sed, awk, shell scripting, and many other programming languages. The most important feature is that it integrates the Regular Expression
#! /Usr/bin/perluse Mail: Sender; # A new sender defines the encoding format to prevent garbled characters. my $ sender = new Mail: Sender {ctype => 'text/plain; charset = utf-8 ', encoding => 'utf-8', };# die "Error in mailing: $ Mail: Sender:
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.