Perl 6 new syntax
This is an incomplete list just to bring you the small overview for the Perl 6 new syntax.
- Global variables use twigil. It is the second character in the variable name.
Was: $ENV{FOO}
Now: %*ENV
-
eval {}is now try {} -
foreach becomes for
-
for becomes loop
4.no parens on control structure conditions (Larry you did it again)
Was: if ($a < $b) { … }
Now: if $a < $b { … }
-
string concatenation is now done with ~.
-
still the same contexts: void, item (scalar) and list, but operators can force the special context
-
the command-line arguments are now in @ARGS</strong>, not
@ARGV. Note the * twigil because @ARGS is a global. -
The double-underscore keywords are gone
LINE is gone
and now: $?LINE
FILE is gone
and now: $?FILE
PACKAGE is gone
and now: $?PACKAGE
END is gone
and now: =begin END
DATA is gone
and now =begin DATA
- @array.elems for number of elements in an array:
Was: $#array+1 or scalar(@array)
10 @array.end to get the index of last element in an array:
Was: $#array
9-10 combined. to get the last element of the array@array[@array.end]
Was: $array[$#array]
…
tags: & category: -