@@ -1119,7 +1119,8 @@ a better choice for grammar reuse.
1119
1119
1120
1120
= head2 Named captures
1121
1121
1122
- These work in a slightly different way; also they only work in the latest versions of Perl 5.
1122
+ These work in a slightly different way; also they only work in the latest
1123
+ versions of Perl 5.
1123
1124
1124
1125
= for code :lang<perl5>
1125
1126
use v5.22;
@@ -1154,15 +1155,14 @@ differences!
1154
1155
1155
1156
= head2 UNITCHECK becomes CHECK
1156
1157
1157
- There is currently B < no > direct equivalent of C < CHECK > blocks in Perl 6.
1158
- The C < CHECK > phaser in Perl 6 has the same semantics as the C < UNITCHECK >
1159
- block in Perl 5: it gets run whenever the compilation unit in which it
1160
- occurs, has finished parsing. This is considered a much saner semantic
1161
- than the current semantics of C < CHECK > blocks in Perl 5. But for
1162
- compatibility reasons, it was impossible to change the semantics of C < CHECK >
1163
- blocks in Perl 5, so a C < UNITCHECK > block was introduced in 5.10. So it
1164
- was decided that the Perl 6 C < CHECK > phaser would follow the saner Perl 5
1165
- C < UNITCHECK > semantics.
1158
+ There is currently B < no > direct equivalent of C < CHECK > blocks in Perl 6. The
1159
+ C < CHECK > phaser in Perl 6 has the same semantics as the C < UNITCHECK > block in
1160
+ Perl 5: it gets run whenever the compilation unit in which it occurs has
1161
+ finished parsing. This is considered a much saner semantic than the current
1162
+ semantics of C < CHECK > blocks in Perl 5. But for compatibility reasons, it was
1163
+ impossible to change the semantics of C < CHECK > blocks in Perl 5, so a
1164
+ C < UNITCHECK > block was introduced in 5.10. Consequently, it was decided that
1165
+ the Perl 6 C < CHECK > phaser would follow the saner Perl 5 C < UNITCHECK > semantics.
1166
1166
1167
1167
= head2 No block necessary
1168
1168
@@ -1178,11 +1178,11 @@ BEGIN my $foo = 42; # Perl 6
1178
1178
1179
1179
= head2 Changed semantics with regards to precompilation
1180
1180
1181
- If you put C < BEGIN > and C < CHECK > phasers in a module that is being
1182
- precompiled, then these phasers will B < only > be executed during precompilation
1183
- and B < not > when a precompiled module is being loaded. So when porting module
1184
- code from Perl 5, you may need to change C < BEGIN > and C < CHECK > blocks to
1185
- C < INIT > blocks to ensure that they're run when loading that module.
1181
+ If you put C < BEGIN > and C < CHECK > phasers in a module that is being precompiled,
1182
+ then these phasers will B < only > be executed during precompilation and B < not >
1183
+ when a precompiled module is being loaded. So when porting module code from
1184
+ Perl 5, you may need to change C < BEGIN > and C < CHECK > blocks to C < INIT > blocks to
1185
+ ensure that they're run when loading that module.
1186
1186
1187
1187
= head1 Pragmas
1188
1188
@@ -1195,7 +1195,7 @@ Strict mode is now on by default.
1195
1195
Warnings are now on by default.
1196
1196
1197
1197
C < no warnings > is currently L < NYI|/language/glossary#NYI > ,
1198
- but putting things in a quietly {} block will silence.
1198
+ but putting things in a C < quietly > {} block will silence.
1199
1199
1200
1200
= head3 C < autodie >
1201
1201
@@ -1281,10 +1281,11 @@ time being, only utf8 for its scripts.
1281
1281
= head3 C < integer >
1282
1282
1283
1283
Perl pragma to use integer arithmetic instead of floating point. There is
1284
- no such equivalent in Perl 6. If you use native integers in your calculations,
1284
+ no such thing in Perl 6. If you use native integers in your calculations,
1285
1285
then this will be the closest thing.
1286
1286
1287
1287
= for code
1288
+ #Perl 6
1288
1289
my int $foo = 42;
1289
1290
my int $bar = 666;
1290
1291
say $foo * $bar; # uses native integer multiplication
@@ -1382,7 +1383,8 @@ Removed.
1382
1383
1383
1384
= item C < -P > C < -u > C < -U > C < -W > C < -X >
1384
1385
1385
- Removed. See L < S19#Removed Syntactic Features|https://design.perl6.org/S19.html#Removed_Syntactic_Features > .
1386
+ Removed. See
1387
+ L < Removed Syntactic Features|https://design.perl6.org/S19.html#Removed_Syntactic_Features > .
1386
1388
1387
1389
= item C < -w >
1388
1390
@@ -1429,16 +1431,18 @@ the C<lines> method on the result of C<slurp> instead:
1429
1431
1430
1432
my @lines = "test-file".IO.slurp.lines; # also auto-chomps
1431
1433
1432
- Also, be aware that $! is not really relevant for file IO operation failures in
1433
- Perl 6. An IO operation that fails will return a failure instead of throwing an
1434
- exception. If you want to return the failure message, it is in the failure
1435
- itself, not in $!. To do similar IO error checking and reporting as in Perl 5:
1434
+ Also, be aware that C < $! > is not really relevant for file IO operation failures
1435
+ in Perl 6. An IO operation that fails will return a C < Failure > instead of
1436
+ throwing an exception. If you want to return the failure message, it is in the
1437
+ failure itself, not in C < $! > . To do similar IO error checking and reporting as
1438
+ in Perl 5:
1436
1439
1437
1440
my $fh = open('./bad/path/to/file', :w) or die $fh;
1438
1441
1439
- Note: $fh instead of $!. Or, you can set $_ to the failure and die with $_:
1442
+ I < Note > : C < $fh > instead of C < $! > . Or, you can set C < $_ > to the failure and die
1443
+ with $_:
1440
1444
1441
- my $fh = open('./bad/path/to/file', :w) orelse .die;
1445
+ my $fh = open('./bad/path/to/file', :w) orelse .die; # Perl 6
1442
1446
1443
1447
Any operation that tries to use the failure will cause the program to fault and
1444
1448
terminate. Even just a call to the C < .self > method is sufficient.
@@ -1454,7 +1458,7 @@ my $arg = 'Hello';
1454
1458
my $captured = `echo \Q$arg\E`;
1455
1459
my $captured = qx(echo \Q$arg\E);
1456
1460
1457
- Or using String::ShellQuote (because C < \Q…\E > is not completely right):
1461
+ Or using C < String::ShellQuote > (because C < \Q…\E > is not completely right):
1458
1462
1459
1463
= for code :lang<perl5>
1460
1464
my $arg = shell_quote 'Hello';
@@ -1477,7 +1481,7 @@ But beware that in this case there is B<no protection at all>! C<run> does
1477
1481
not use the shell, so there is no need to escape the arguments (arguments
1478
1482
are passed directly). If you are using C < shell > or C < qqx > , then everything
1479
1483
ends up being one long string which is then passed to the shell. Unless you
1480
- validate your arguments very carefully, there is a high chance to introduce
1484
+ validate your arguments very carefully, there is a high chance of introducing
1481
1485
shell injection vulnerabilities with such code.
1482
1486
1483
1487
= head1 Environment variables
@@ -1541,7 +1545,7 @@ In Perl 6 becomes a simple
1541
1545
1542
1546
Gone.
1543
1547
1544
- The Perl 6 design allows for automatic transparent saving-and-loading of
1548
+ The Perl 6 design allows for automatic and transparent saving-and-loading of
1545
1549
compiled bytecode.
1546
1550
1547
1551
Rakudo supports this only for modules so far.
0 commit comments