• Introduction to the command (use, Perl)


    1. do: 1) Form: do ‘filename’;explain:Here, the filename needs to be added with single quotation marks, otherwise an error will occur;Filename can be any suffix, or even no suffix. It is not required to be PL or PM. 2) Understanding of do: do ‘filename’First, you need to read in the file of filename (if reading […]

  • Share the method of realizing front and background docking with Perl glue


    1. Perl “glue” can combine various applications or codes in various languages.Perl can write ordinary script programs, use CGI module to write web applications, and use DBI to access various databases.In addition, Perl can glue various levels of applications together to play a more powerful function. 2.The foreground is a website web application. The bottom […]

  • Application introduction of Perl Localtime function


    1. General use: @nowtime=localtime(); #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();be careful: $mon+1,$year+1900; $now_string = localtime;  # e.g., “Thu Oct 13 04:54:34 1994” 2. If you want to save the time in the database, you can first save it as a string, and then process the string when reading it. @nowtime=localtime(); $nowstring=join(‘,’,@nowtime);Save $nowstring;Read: @nowtime=split(‘,’,$nowstring); For more information, please refer […]

  • Implementation method of running Perl CGI program with Apache 2 in CGI mode


    1. Linux system usually comes with PerlThe runnable program is in: / usr / bin / Perl 2. Perl test program Copy codeThe code is as follows: #!/usr/bin/perl -w use warnings; print “Hello, Perl works!  “;   Named test pl Under the terminal, locate the directory and enter Perl test If PL and Perl work […]

  • Introduction to XML processing module of Perl


    1. Find existing modules http://search.cpan.org/ 2. Input XML query and select the module with high evaluation that can meet your own needs: XML::Simple use warnings; use XML::Simple; use Data::Dumper; #Convert XML file to hash result   Copy codeThe code is as follows: my $xml=XMLin(‘abstract_sample.xml’); open(HASH,’>>XML_hash’)||die”can not open the file: $!”; print HASH Dumper($xml);   #To […]

  • Two implementation methods of Perl reading string from file


    1. Read all contents in the file into an array at one time (this method is suitable for small files):     Copy codeThe code is as follows: open(FILE,”filename”)||die”can not open the file: $!”; @filelist=<FILE>;   foreach $eachline (@filelist) {         chomp $eachline; } close FILE; @filelist=<FILE>;   When the file is large, an “out […]

  • Some knowledge of scalar operators and Perl


    1. Perl makes general variablesscalar, the direct quantity that this variable can refer to includes two types: digital direct quantity; String direct quantity. a) Representation of string:Single quotation mark, the meaning of the string in single quotation mark is intuitive, and there is no need to calculate the variable value and escape character;Double quotation marks. […]

  • Introduction to Perl control flow (if condition, while, for loop, foreach)


    1. Statement block:The part between {} is the block statement block. 2. Conditional statements: if ( expression )  BLOCK; if ( expression )     BLOCK1 else BLOCK2; if ( expression1 )     BLOCK1; elsif ( expression2 )    BLOCK2; else     BLOCK3; #Inverted if statement expression if ( test_expression ); Relational operators involved:Numeric value comparison: […]

  • Classic usage sharing of Perl file reading


    Open the file with the open() function Common methods of opening files are:   Copy codeThe code is as follows: open(FH, “< $filename”) or die “Couldn’t open $filename for reading: $!”;   The open() function usually takes two parameters. The first parameter is the file handle, which is used to point to the open file. […]

  • Introduction of Perl large file reading and processing module


    The module uses Perl’s array to represent a file. Each line of the file corresponds to an element of the array. The first line element is 0, the second line is 1  The file itself is not actually loaded into memory, and the operation on the array elements immediately acts on the file. The biggest […]

  • Perl skip the first line to read the implementation code of the file


    Copy codeThe code is as follows: #!/usr/bin/perl open( READ, “<$file” ); readline READ; # skip the first line while (<READ>) { my ( $id, $axis1, $axis2, $axis3, $value ) = split / /; $line = sprintf ( “%d %d %d %d %d %d”, $id, $axis1, $axis2, $axis3, $value, $axis1 + $axis2 ); print WRITE $line; […]

  • Perl split string split function usage guide


    This article focuses on the usage of Perl split function. A very useful function in Perl is Perl split function – dividing a string and putting the divided result into an array. This Perl split function uses a regular expression (RE) and works in if not specified$_ Variable. Perl split function A very useful function […]