Structures

Structures are used to define control flow of the application. Each of them is treated as a single command, so they can be nested into each other. Most of these structures feature curly brackets. Unlike other programming languages, Perun2 forces user to always write them.


Comments

single-line // [content]
multi-line /* [content] */
Perun2 enables two types of comments.

Command Sequence

[command] ; [command]
Semicolons can be used to separate multiple commands. Separated commands are run sequentially. Semicolon works in Perun2 as a separator rather than as an end of command symbol.

Condition

if [bool] { [command] }
if [bool] { [command] } else if [bool] { [command] }
if [bool] { [command] } else { [command] }
A conditional statement can be followed by optionary else if and else blocks.

While

while [bool] { [command] }
The command is run as long as the condition is satisfied.

Repeat Loop

[number] times { [command] }
Embraced command is repeated a certain number of times.

Iteration Loop

[list] { [command] }
foreach [list] { [command] }
Iteration over collections is very simplified in Perun2 and requires barely a pair of curly brackets. The current element of the collection can be obtained from the variable this, while variable index refers to the iteration counter (starting from 0). Every element is casted into string and is treated as a file name. We can access attributes of this file in the internal command block.

Inside

inside [list] { [command] }
The command is executed for every argument working location. Directories that do not exist in the file system are omitted.