1. Read all the contents of the file into an array at once (this method is suitable for small files):
Copy Code code as follows:
Open (FILE, "filename") | | Die "Can not open the file: $!";
@filelist =;
foreach $eachline (@filelist)
Sometimes it is troublesome to encounter rows or columns that are inconsistent in length, although you can fill the file with the longest row (column) in R, but it is inconvenient, so remember to use Perl to achieve one.The indefinite length text
Using Perl to dispatch SQL scripts, in the process of opening a number of processes, I found that Perl write log file order disorder, do not want to engage in multi-threading programming so troublesome, my processing method, the corresponding file
The Perl installation steps on the Unix/linux system are as follows:
Open http://www.perl.org/get.html through the browser.
Download the source package for Unix/linux.
After you download the perl-5.x.y.tar.gz file, perform the
subroutine definition and return valueSub sum{ print" called sub-program \ n"; $a $b # The latter behavior returns a value }$a=1; $b=; $s # 34 Calling SubroutinesSub-program parameters, parameters fixed (The following example can only 2
1. Time Function: returns the number of seconds that have elapsed since January 1, January 1, 1970.Use: My $ t = time ();
2. localtime function: Get the local time zoneUse: My $ T = localtime (Time ());
3. gmtime function: Get Greenwich Mean
Have you ever encountered a phenomenon where too many directory files cannot be deleted on UNIX? I wrote a Perl
ProgramDelete
CopyCodeThe Code is as follows: CAT> Del. pl
#! /Usr/bin/perl
$ File1 = $ argv [0];
@ Tests = (1, 2, 3, 4, 5, 6, 7, 8
1. ChildProgram(In common ?), It starts with "&" in a call to distinguish it from "$" and @2. the scalar in the subroutine block is global without any modification. This subroutine is called multiple times in a file and can be modified multiple
#! Usr/bin/perlUse Statistics: R;# --- New FunctionMy $ r = statistics: R-> New ();# --- Send and read Functions$ R-> send (qq 'a = C (1, 2, 3, 4); B = mean (a); \ n C = SQRT (B); print (c )');My $ result = $ R-> read;Print $ result, "\ n ";# ---
Here are two examples for your reference.
Record the function running time for any function.
Copy codeThe Code is as follows :#! /Usr/bin/perl
Use warnings;
Use strict;
No strict "refs ";
Sub testLogToStd {
Print "Test stdout: \ n ";
Open LOG, ">
1. Perl converts a common variable into a scalar. This variable can refer to two types of direct quantities: Numeric direct quantities and string direct quantities.
A) String Representation Method:Single quotes: the meaning of strings in single
1. Read all the content in the file into an array at a time (this method is suitable for small files ):
Copy codeThe Code is as follows: open (FILE, "filename") | die "can not open the file: $! ";
@ Filelist = ;
Foreach $ eachline (@
1. Single Line (large file processing ):
Copy codeThe Code is as follows: my $ oneline = or
While ($ line = )
{}
2. Read all (small File Processing ):
Copy codeThe Code is as follows: open (my $ in, "path") or die "open error: $! ";
My @ lines = ;
Operate (generate) Excel on Linux or Unix. CPAN provides the Spreadsheet: WriteExcel and Spreadsheet: ParseExcel modules.
Let's take a look at how to use Spreadsheet: WriteExcel and Spreadsheet: ParseExcel.
First, install the corresponding modules
Perl has the best text data processing capabilities. this is what everyone knows. in perl, some software does not have small functions, namely the Perl format. it is equivalent to a simple command line report and chart output. the format must be
How to get all the members in user group by using LDAP in Perl ?, Ldapperl
About LDAP:
LDAP stands for Lightweight Directory Access Protocol. It is usually used to fetch (and sometimes update) data in a directory of people.
Using Net: LDAP module in
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.