@@ -248,9 +248,9 @@ in C<$x> containing "howdy".
248
248
Note that C < chomp() > (without arguments) is not supported in Perl 6.
249
249
250
250
The Perl 6 ecosystem has a module C < P5chomp > which exports a C < chomp >
251
- function that mimics the original Perl 5 behaviour as much as possible,
251
+ function that mimics the original Perl 5 behaviour as much as possible.
252
252
253
- = head2 chop
253
+ . head2 chop
254
254
255
255
= item chop VARIABLE
256
256
@@ -261,9 +261,9 @@ being "howdy" and C<$y> being "howd". Also works as a method: C<$y = $x.chop>.
261
261
Note that C < chop() > (without arguments) is not supported in Perl 6.
262
262
263
263
The Perl 6 ecosystem has a module C < P5chomp > which exports a C < chop >
264
- function that mimics the original Perl 5 behaviour as much as possible,
264
+ function that mimics the original Perl 5 behaviour as much as possible.
265
265
266
- = head2 chown
266
+ . head2 chown
267
267
268
268
= item chown LIST
269
269
@@ -283,7 +283,7 @@ function and a method:
283
283
Note that C < chr() > (without arguments) is not supported in Perl 6.
284
284
285
285
The Perl 6 ecosystem has a module C < P5chr > which exports a C < chr >
286
- function that mimics the original Perl 5 behaviour as much as possible,
286
+ function that mimics the original Perl 5 behaviour as much as possible.
287
287
288
288
= head2 chroot
289
289
@@ -363,7 +363,7 @@ considered undefined.
363
363
Note that C < defined() > (without arguments) is not supported in Perl 6.
364
364
365
365
The Perl 6 ecosystem has a module C < P5defined > which exports a C < defined >
366
- function that mimics the original Perl 5 behaviour as much as possible,
366
+ function that mimics the original Perl 5 behaviour as much as possible.
367
367
368
368
= head2 delete
369
369
@@ -419,7 +419,7 @@ L<https://design.perl6.org/S06.html#%22Pointy_blocks%22>. There is also
419
419
some information at L < https://en.wikibooks.org/wiki/Perl_6_Programming/Blocks_and_Closures#Pointy_Blocks >
420
420
421
421
The Perl 6 ecosystem has a module C < P5each > which exports an C < each >
422
- function that mimics the original Perl 5 behaviour as much as possible,
422
+ function that mimics the original Perl 5 behaviour as much as possible.
423
423
424
424
= head2 eof
425
425
@@ -434,7 +434,8 @@ C<$filehandle.eof>. Returns C<True> if at end of file.
434
434
435
435
= item eval EXPR
436
436
437
- Replaced by L < EVAL|/routine/EVAL > . Note that C < EVAL > does not do any L < exception handling|/language/exceptions > !
437
+ Replaced by L < EVAL|/routine/EVAL > . Note that C < EVAL > does not do any
438
+ L < exception handling|/language/exceptions > !
438
439
439
440
= head2 evalbytes
440
441
@@ -492,7 +493,11 @@ Same as in Perl 5, but can also be used as a method: C<5.exp>;
492
493
493
494
= item fc EXPR
494
495
495
- Looks like it does the same thing as in Perl 5.
496
+ Looks like it does the same thing as in Perl 5 except that calling it without
497
+ arguments is not supported in Perl 6.
498
+
499
+ The Perl 6 ecosystem has a module C < P5fc > which exports a C < fc >
500
+ function that mimics the original Perl 5 behaviour as much as possible.
496
501
497
502
= head2 fcntl
498
503
@@ -510,8 +515,11 @@ Replaced by C<$?FILE>.
510
515
511
516
= item fileno FILEHANDLE
512
517
513
- S32 indicates that this should be available as a method, but appears currently
514
- unimplemented.
518
+ The C < native-descriptor > method on C < IO::Handle > returns the equivalent of
519
+ C < fileno > .
520
+
521
+ The Perl 6 ecosystem has a module C < P5fileno > which exports a C < fileno >
522
+ function that mimics the original Perl 5 behaviour as much as possible.
515
523
516
524
= head2 flock
517
525
@@ -673,7 +681,10 @@ C<DateTime> object for the current time, for instance, use C<my $gmtime
673
681
674
682
= item goto &NAME
675
683
676
- goto is not yet implemented
684
+ The syntax for C < goto LABEL > is already accepted, but the runtime part of
685
+ C < goto > is not yet implemented. So this will result in a runtime error:
686
+
687
+ FOO: goto FOO; # Label.goto() not yet implemented. Sorry.
677
688
678
689
= head2 grep
679
690
@@ -689,6 +700,8 @@ also be used as a method: C<@foo = @bar.grep(/^f/)>
689
700
690
701
= item hex EXPR
691
702
703
+ In Perl 6 an expression B < must > be specified.
704
+
692
705
Replaced by the adverbial form C < :16 > . E. g. C < :16("aF") > returns 175.
693
706
694
707
Alternately, the same result can be achieved by using the C < .base > method:
@@ -698,6 +711,9 @@ It just so happens that C<.Str> defaults to base 10, so if you just C<say
698
711
0xaF > , that will also print 175, but that may not be immediately obvious, so
699
712
may not be the best way to go for this.
700
713
714
+ The Perl 6 ecosystem has a module C < P5hex > which exports a C < hex >
715
+ function that mimics the original Perl 5 behaviour as much as possible.
716
+
701
717
= head2 import
702
718
703
719
= item import LIST
@@ -713,7 +729,19 @@ L<this section|/language/5to6-nutshell#Importing_specific_functions_from_a_modul
713
729
= item index STR, SUBSTR, POSITION
714
730
715
731
Works as in Perl 5. Can also now be used as a method:
716
- C < "howdy!".index("how"); # 0 >
732
+ C < "howdy!".index("how"); # 0 > . Main difference with Perl 5 is that C < Nil > is
733
+ returned instead of C < -1 > . This is very useful in combination with the
734
+ C < with > command:
735
+
736
+ with index("foo","o") -> $index {
737
+ say "Found it at $index";
738
+ }
739
+ else {
740
+ say "Not found"
741
+ }
742
+
743
+ The Perl 6 ecosystem has a module C < P5index > which exports an C < index >
744
+ function that mimics the original Perl 5 behaviour as much as possible.
717
745
718
746
= head2 int
719
747
@@ -725,6 +753,14 @@ translation of Perl 5 code, but in Perl 6, you can just as easily call
725
753
the C < .Int > method on the number. C < 3.9.Int; # 3 > and C < 3.9.truncate >
726
754
are equivalent.
727
755
756
+ Please note that C < int > B < does > have a meaning in Perl 6. It is type that
757
+ can be used to indicate a native integer:
758
+
759
+ my int $a = 42; # a native integer, similar to Perl 5's integer values
760
+
761
+ Because of this, it has proven impossible to create a Perl 6 module that
762
+ would export a sub that would mimic the Perl 5 behaviour.
763
+
728
764
= head2 ioctl
729
765
730
766
= item ioctl FILEHANDLE, FUNCTION, SCALAR
@@ -773,21 +809,31 @@ Same as in Perl 5.
773
809
774
810
= item lc EXPR
775
811
776
- Works as in Perl 5, and also as a method: C < "UGH".lc >
812
+ Works as in Perl 5, and also as a method: C < "UGH".lc > . In Perl 6 an
813
+ expression B < must > be specified.
814
+
815
+ The Perl 6 ecosystem has a module C < P5lc > which exports an C < lc >
816
+ function that mimics the original Perl 5 behaviour as much as possible.
777
817
778
818
= head2 lcfirst
779
819
780
820
= item lcfirst EXPR
781
821
782
822
Does not exist in Perl 6.
783
823
824
+ The Perl 6 ecosystem has a module C < P5lcfirst > which exports an C < lcfirst >
825
+ function that mimics the original Perl 5 behaviour as much as possible.
826
+
784
827
= head2 length
785
828
786
829
= item length EXPR
787
830
788
831
Replaced by C < chars > , typically used as a method (C < $string.chars > ), but
789
832
also works as a function.
790
833
834
+ The Perl 6 ecosystem has a module C < P5length > which exports an C < length >
835
+ function that mimics the original Perl 5 behaviour as much as possible.
836
+
791
837
= head2 __LINE__
792
838
793
839
= item __LINE__
@@ -847,14 +893,16 @@ lines of "2015-06-29T12:49:31-04:00".
847
893
848
894
= item lock THING
849
895
850
- In Perl 6, a method in the C < Lock > class.
896
+ There currently is no equivalent for this In Perl 6. There is a C < Lock >
897
+ class for creating a Lock object, that can be locked/unlocked as needed.
898
+ But such a lock does not refer to any external objects.
851
899
852
900
= head2 log
853
901
854
902
= item log EXPR
855
903
856
- Available in Perl 6. Also works as a method. I. e. C < log(2) > is
857
- equivalent to C < 2.log > .
904
+ Available in Perl 6, but B < must > have an expression to work on. Also available
905
+ as a method. I. e. C < log(2) > is equivalent to C < 2.log > .
858
906
859
907
= head2 lstat
860
908
@@ -896,7 +944,10 @@ used as a method: C<@new = @old.map: { $_ * 2 }>
896
944
897
945
= item mkdir FILENAME
898
946
899
- Works as in Perl 5.
947
+ Works as in Perl 5. When giving a multi-level directory specification,
948
+ it will automatically create non-existing intermediate directories with
949
+ the same MASK (similar to what "make_path" does of the File::Path module
950
+ in Perl 5).
900
951
901
952
= item mkdir
902
953
@@ -958,6 +1009,9 @@ Replaced by the adverbial form C<:8>. E. g. C<:8("100")> returns 64.
958
1009
If you want to deal with strings that start in C < 0x > , C < 0o > , or C < 0b > ,
959
1010
you can just use the C « prefix:<+> » operator.
960
1011
1012
+ The Perl 6 ecosystem has a module C < P5hex > which exports an C < oct >
1013
+ function that mimics the original Perl 5 behaviour as much as possible.
1014
+
961
1015
= head2 open
962
1016
963
1017
= item open FILEHANDLE, EXPR
@@ -990,6 +1044,11 @@ No replacement. See L«C<&dir>/C<IO::Path.dir>|/routine/dir» for alternatives.
990
1044
991
1045
Same as in Perl 5. May be used as a method: C < "howdy!".ord; # 104 >
992
1046
1047
+ Note that C < ord() > (without arguments) is not supported in Perl 6.
1048
+
1049
+ The Perl 6 ecosystem has a module C < P5chr > which exports a C < ord >
1050
+ function that mimics the original Perl 5 behaviour as much as possible.
1051
+
993
1052
= head2 our
994
1053
995
1054
= item our VARLIST
@@ -1006,9 +1065,15 @@ The same in Perl 6.
1006
1065
1007
1066
= item pack TEMPLATE, LIST
1008
1067
1009
- Available in Perl 6. The template options are currently more restricted
1010
- than they are in Perl 5. The current documented list can be found at
1011
- L < unpack|/routine/unpack > .
1068
+ Available in Perl 6 when C < use experimental :pack > has been specified in the
1069
+ scope where C < pack > needs to be called. The template options are currently
1070
+ more restricted than they are in Perl 5. The current documented list can be
1071
+ found at L < unpack|/routine/unpack > .
1072
+
1073
+ The Perl 6 ecosystem has a module C < P5pack > which exports a C < pack >
1074
+ function that mimics the original Perl 5 behaviour as much as possible
1075
+ and which has a bigger set of supported features than the experimental
1076
+ Perl 6 version.
1012
1077
1013
1078
= head2 package
1014
1079
@@ -1051,6 +1116,23 @@ and from processes.
1051
1116
Works in Perl 6, and can also be used as a method. I. e. C < my $x = pop
1052
1117
@a; > and C < my $x = @a.pop; > are equivalent.
1053
1118
1119
+ The non-paramater version of C < pop > does not exist. Also, if the array
1120
+ is empty, a Failure will be returned in Perl 6, which will throw if the
1121
+ value is actually used in a significant way.
1122
+
1123
+ If you are using only defined values in your array, you can use the C < with >
1124
+ function to handle this case:
1125
+
1126
+ with pop @array -> $popped {
1127
+ say "popped '$popped' of the array";
1128
+ }
1129
+ else {
1130
+ say "there was nothing to pop";
1131
+ }
1132
+
1133
+ The Perl 6 ecosystem has a module C < P5push > which exports a C < pop >
1134
+ function that mimics the original Perl 5 behaviour as much as possible
1135
+
1054
1136
= head2 pos
1055
1137
1056
1138
= item pos SCALAR
0 commit comments