Skip to content

Commit da19f67

Browse files
authored
Merge pull request #1598 from perl6/molecules-patch-2
File test adverb forms with links to method forms
2 parents f09992e + fc97c39 commit da19f67

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/Type/IO/Path.pod6

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,35 @@ my $perl-files = gather while @stack {
547547
}
548548
.put for $perl-files[^3];
549549
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+
550579
=head2 method e
551580
552581
Defined as:

0 commit comments

Comments
 (0)