Perl6::Overview::Control - Control Structure
while EXPR { ... } until EXPR { ... } loop { ... }; loop ($i = 0; $i < 10; $i++) { ... } repeat { ... } while EXPR; repeat { ... } until EXPR; repeat while EXPR { ... } repeat until EXPR { ... }
for @foo { ... } for @foo -> $x { ... } for @foo -> $x, $y, $z { ... } for @foo.kv -> $index, $value { ... } for %hash.kv -> $key, $value { ... } for =<> {...} # was while (<>) { ... } in p5
given $x { ... } # $x is now topic for block when EXPR { ... } # perform $_ ~~ EXPR execute block and break default { ... } # same as when true { ... }
BEGIN { ... } # Body executed at compile-time, as soon as possible CHECK { ... } # Body executed at compile-time, as last as possible INIT { ... } # Body executed at runtime, as soon as possible END { ... } # Body executed at runtime, as last as possible START { ... } # Body only executed once (per clone), inline sub foo { START { # Initialize environment, e.g. create some files, etc. } ...; } foo(); # Runs initialization block foo(); # Does not run initialization block again foo(); # ditto
To install Perl6::Doc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl6::Doc
CPAN shell
perl -MCPAN -e shell install Perl6::Doc
For more information on module installation, please visit the detailed CPAN module installation guide.