1. Statement block:
The parts between {} Are BLOCK statement blocks.
2. Condition Statement:
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: =,>, <, >=, <= ,! =; When comparing strings with numeric values, the string is treated as 0;
String comparison: eq, gt, lt, ge, le, ne; (undef is treated as false)
Logical operators: &, |, and! ; And, or, not, and so on.
3. Loop:
While (expression)
BLOCK;
Do
BLOCK
While (expression );
For (initialization; test; increment)
BLOCK;
Foreach $ each (@ list)
BLOCK;
4. Miscellaneous
Last: The last time, the current BLOCK exists, and the Code following the BLOCK goes down.
Next: This time till now, the next round of this BLOCK is started.
Label: similar to goto.
Last and next are usually used in combination with if inverted statements or labels to achieve redirection.
Exit statement: exit 0; end the current Perl program and return OS;
Note: Perl does not have a switch statement. if-else is used for imitation.