@@ -572,7 +572,15 @@ For most file tests, you can do a smartmatch C<~~> or you can call a method.
572
572
You don't need to actually open a filehandle in the traditional way (although
573
573
you can) to do a filetest. You can simply append C < .IO > to the filename. For
574
574
instance, here is how to check if a file is readable using smartmatch:
575
- C < '/path/to/file'.IO ~~ :r >
575
+
576
+ '/path/to/file'.IO ~~ :r;
577
+
578
+ L « Smartmatching on Pairs|/type/Pair#method_ACCEPTS » is useful for performing
579
+ multiple file tests:
580
+
581
+ say :d & :x; # OUTPUT: «all(d => True, x => True)»
582
+ say '/tmp'.IO ~~ :d & :x; # OUTPUT: «True»
583
+ say '/'.IO ~~ :d & :rw; # OUTPUT: «False»
576
584
577
585
You can, of course, use an already opened filehandle. Here, using the filehandle
578
586
C < $fh > , is an example, using the method syntax for the file test:
@@ -607,9 +615,6 @@ Defined as:
607
615
608
616
Returns C < True > if the invocant is a path that exists.
609
617
610
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
611
- file tests.
612
-
613
618
= head2 method d
614
619
615
620
Defined as:
@@ -620,9 +625,6 @@ Returns C<True> if the invocant is a path that exists and is a directory.
620
625
The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the
621
626
path points to a non-existent filesystem entity.
622
627
623
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
624
- file tests.
625
-
626
628
= head2 method f
627
629
628
630
Defined as:
@@ -633,9 +635,6 @@ Returns C<True> if the invocant is a path that exists and is a file. The method
633
635
will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the path points to
634
636
a non-existent filesystem entity.
635
637
636
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
637
- file tests.
638
-
639
638
= head2 method s
640
639
641
640
Defined as:
@@ -649,9 +648,6 @@ a non-existent filesystem entity.
649
648
650
649
say $*EXECUTABLE.IO.s'; # OUTPUT : «467»
651
650
652
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
653
- file tests.
654
-
655
651
= head2 method l
656
652
657
653
Defined as:
@@ -662,9 +658,6 @@ Returns C<True> if the invocant is a path that exists and is a symlink.
662
658
The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the
663
659
path points to a non-existent filesystem entity.
664
660
665
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
666
- file tests.
667
-
668
661
= head2 method r
669
662
670
663
Defined as:
@@ -675,9 +668,6 @@ Returns C<True> if the invocant is a path that exists and is accessible.
675
668
The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the
676
669
path points to a non-existent filesystem entity.
677
670
678
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
679
- file tests.
680
-
681
671
= head2 method w
682
672
683
673
Defined as:
@@ -688,9 +678,6 @@ Returns C<True> if the invocant is a path that exists and is writable.
688
678
The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the
689
679
path points to a non-existent filesystem entity.
690
680
691
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
692
- file tests.
693
-
694
681
= head2 method rw
695
682
696
683
Defined as:
@@ -701,9 +688,6 @@ Returns C<True> if the invocant is a path that exists and is readable and
701
688
writable. The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist >
702
689
if the path points to a non-existent filesystem entity.
703
690
704
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
705
- file tests.
706
-
707
691
= head2 method x
708
692
709
693
Defined as:
@@ -714,9 +698,6 @@ Returns C<True> if the invocant is a path that exists and is executable.
714
698
The method will L « C < fail > |/routine/fail» with C < X::IO::DoesNotExist > if the
715
699
path points to a non-existent filesystem entity.
716
700
717
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
718
- file tests.
719
-
720
701
= head2 method rwx
721
702
722
703
Defined as:
@@ -727,9 +708,6 @@ Returns C<True> if the invocant is a path that exists and is executable,
727
708
readable, and writable. The method will L « C < fail > |/routine/fail» with
728
709
C < X::IO::DoesNotExist > if the path points to a non-existent filesystem entity.
729
710
730
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
731
- file tests.
732
-
733
711
= head2 method z
734
712
735
713
Defined as:
@@ -743,9 +721,6 @@ is dependent on the operating system. The method will L«C<fail>|/routine/fail»
743
721
with C < X::IO::DoesNotExist > if the path points to a non-existent filesystem
744
722
entity.
745
723
746
- TIP: use L « smartmatch with Pairs|/type/Pair#method_ACCEPTS » to perform multiple
747
- file tests.
748
-
749
724
= head2 method sibling
750
725
751
726
Defined as:
0 commit comments