Code:
Use Strict;
Use Warnings;
My $ Test="ASDF";
Print "$ {Test} _ Test2 \ n";
#Constant
UseConstant {
AAA =>"Aaa",
Bbb =>"Bbb",
Min_total =>12,
Score_pass =>90,
Score_red =>70,
};
PrintAAA;
PrintScore_pass;
# Two dimesion Arrays
My @ Steps = (
[ " Aaa " , " Aaavalue " ],
[ " Bbb " , " Bbbvalue " ],
[ " CCC " , " Cccvalue " ]
);
Print " \ N " ;
Foreach My $ I ( 0 ... $ # Steps ){
Print " $ Steps [$ I] [0]: $ steps [$ I] [1] \ n " ;
}
Code 2:
My $ A1 ;
Print " $ A1 \ n " ;
My $ A2 = UNDEF ;
Print " $ A2 \ n " ;
If (! Defined ( $ A1 )){ Print " A1 is not defined \ n " ;}
If (! $ A2 ){ Print " A2 is not defined \ n " ;}
My $ A3 = '' ;
If (! $ A3 ){ Print " A3 is empty string \ n " ;}
Initialization is required when defining variables, or you need to determine whether the variable is defined during use. In many cases, you need to determine whether the variable is a null string. Especially when getopt: long or CGI-> query is used to obtain the parameter, check whether the parameter is defined. If yes, consider giving the default value.
Complete!