Skip to content

Commit 1b50a0f

Browse files
authored
File test adverb forms with links to method forms
Also intended to fix broken link to https://docs.perl6.org/type/IO::Path#File_test_operators from https://docs.perl6.org/language/5to6-perlfunc#Filetests. Much was copied from https://docs.perl6.org/type/IO::Path#File_test_operators.
1 parent 06e8f69 commit 1b50a0f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

doc/Type/IO/Path.pod6

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,31 @@ 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 you can) to do a filetest. You can simply append C<.IO> to the filename. For instance, here is how to check if a file is readable using smart match:
554+
C<'/path/to/file'.IO ~~ :r>
555+
You can, of course, use an already opened filehandle. Here, using the file handle C<$fh>, is an example, using the method syntax for the file test:
556+
    $fh.r
557+
558+
File tests include
559+
:e L«Exists|/type/IO/Path#method_e»
560+
:d L«Directory|type/IO/Path#method_d»
561+
:f L«File|type/IO/Path#method_f»
562+
:l L«Symbolic link|type/IO/Path#method_l»
563+
:r L«Readable|type/IO/Path#method_r»
564+
:w L«Writable|type/IO/Path#method_w»
565+
:x L«Executable|type/IO/Path#method_x»
566+
:s L«Size|type/IO/Path#method_s»
567+
:z L«Zero size|type/IO/Path#method_z»
568+
569+
All of these tests can be used as methods (without the colon).
570+
Three tests, however exist only as methods:
571+
    $fh.modified;
572+
    $fh.accessed;
573+
    $fh.changed;
574+
550575
=head2 method e
551576
552577
Defined as:

0 commit comments

Comments
 (0)