Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the Perl control structures?

Shulou Source: shulou.com Published: 2022-06-01 17:13:43 10月06日 Update

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!

Tags: Output loops conditions content structure control articles values interests functions guys partners arrays documents more knowledge industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn OPPO Reno MariaDB macOS