I have been using Perl for my recent work.Program. Although Perl is not my learning direction, I still summarize some knowledge points I encountered at work for future use.
1. Define a hash (hash or associated array)
% For = (
"AAA" => "001 ",
"BBB" => "002 ",
"CCC" => "003 ",
"DDD" => "004 ",
);
2. Use $ for {"AAA"}, or use the simple variable $ for {$ tmp_par }.
Define a two-dimensional join Array
% For1 = (
"AAA" => "001 ",
"BBB" => "002 ",
"CCC" => "003 ",
"DDD" => "004 ",
);
% For2 = (
"XXX" => "how ",
"Yyy" => "are ",
"Zzz" => "you ",
);
% To_for = (
"0" =>/% for1,
"1" =>/% for2,
);
/Is used to get the addresses of % for1 and % for2.
In this way, you can use$ To_for {"0" }{ "AAA "}001.
3. Recursively call a subroutine in Perl. The subroutine must stop calling itself.CodeSuch as the return statement. In addition, except for variables not changed by the quilt program, all variables must be partially declared using my.
4. Split () ?,., +, * And other characters must be separated by escape/, for example:Split ('/? ', $ Some_string );
5. Put the split string in the array:My @ Temp=Split ('/', $ tmp_s2 );
Then you can use @ temp to get the array size, for example:My $ size = @ temp;$ Size is the temp size of the array.
6. Array loop:
Foreach my $ U (@ arr_tmp)
{
...
}
7. Determines whether a string matches a mode. $ u = ~ is available ~ /Tre | world | MP3/
For example:My $ pattern = "Tre | world | MP3"
If ($ u = ~ /$ Pattern /)
{
# Matching
}