@@ -547,6 +547,35 @@ my $perl-files = gather while @stack {
547
547
}
548
548
.put for $perl-files[^3];
549
549
550
+ = head2 File test operators
551
+
552
+ For most file tests, you can do a smart match C < ~~ > or you can call a method.
553
+ You don't need to actually open a filehandle in the traditional way (although
554
+ you can) to do a filetest. You can simply append C < .IO > to the filename. For
555
+ instance, here is how to check if a file is readable using smart match:
556
+ C < '/path/to/file'.IO ~~ :r >
557
+
558
+ You can, of course, use an already opened filehandle. Here, using the file
559
+ handle C < $fh > , is an example, using the method syntax for the file test:
560
+ $fh.r
561
+
562
+ File tests include
563
+ :e L « Exists|/type/IO/Path#method_e »
564
+ :d L « Directory|type/IO/Path#method_d »
565
+ :f L « File|type/IO/Path#method_f »
566
+ :l L « Symbolic link|type/IO/Path#method_l »
567
+ :r L « Readable|type/IO/Path#method_r »
568
+ :w L « Writable|type/IO/Path#method_w »
569
+ :x L « Executable|type/IO/Path#method_x »
570
+ :s L « Size|type/IO/Path#method_s »
571
+ :z L « Zero size|type/IO/Path#method_z »
572
+
573
+ All of these tests can be used as methods (without the colon).
574
+ Three tests, however exist only as methods:
575
+ $fh.modified;
576
+ $fh.accessed;
577
+ $fh.changed;
578
+
550
579
= head2 method e
551
580
552
581
Defined as:
0 commit comments