What are the Perl control structures?
This article mainly introduces what is the control structure of Perl. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
For:for (initialization; Loop condition; Action 1) {Action 2;}
Exit the loop when the loop condition is not met, for example:
For ($ionometrich i4) {print "$I"; $ibirthday;} # output: 0 1 2 3 4
Print "\ $I = $I\ n"; # output: $I = 5
While is often used to traverse the contents of file input:
Open IN, "inflie" or diebacks!
While (my $line=) {
Print$line
}
Close IN
Next: enter the next cycle
For $I (1.. 4) {
If ($i2) {next;}
Print "$I"
} # output: 2 4
Last: exit the loop
For $I (1.. 4) {
If ($I > 2) {last;}
Print "$I"
} # output: 1 2
These are all the contents of the article "what are the Perl Control structures?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!