Skip to content

Commit 06b56f4

Browse files
committed
IO::Path: Clarify smartmatching on Pairs (closes #2621).
Repeated "TIP" text removed.
1 parent a1bc2eb commit 06b56f4

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

doc/Type/IO/Path.pod6

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,15 @@ For most file tests, you can do a smartmatch C<~~> or you can call a method.
572572
You don't need to actually open a filehandle in the traditional way (although
573573
you can) to do a filetest. You can simply append C<.IO> to the filename. For
574574
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␤»
576584
577585
You can, of course, use an already opened filehandle. Here, using the filehandle
578586
C<$fh>, is an example, using the method syntax for the file test:
@@ -607,9 +615,6 @@ Defined as:
607615
608616
Returns C<True> if the invocant is a path that exists.
609617
610-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
611-
file tests.
612-
613618
=head2 method d
614619
615620
Defined as:
@@ -620,9 +625,6 @@ Returns C<True> if the invocant is a path that exists and is a directory.
620625
The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the
621626
path points to a non-existent filesystem entity.
622627
623-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
624-
file tests.
625-
626628
=head2 method f
627629
628630
Defined as:
@@ -633,9 +635,6 @@ Returns C<True> if the invocant is a path that exists and is a file. The method
633635
will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the path points to
634636
a non-existent filesystem entity.
635637
636-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
637-
file tests.
638-
639638
=head2 method s
640639
641640
Defined as:
@@ -649,9 +648,6 @@ a non-existent filesystem entity.
649648
650649
say $*EXECUTABLE.IO.s'; # OUTPUT : «467␤»
651650
652-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
653-
file tests.
654-
655651
=head2 method l
656652
657653
Defined as:
@@ -662,9 +658,6 @@ Returns C<True> if the invocant is a path that exists and is a symlink.
662658
The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the
663659
path points to a non-existent filesystem entity.
664660
665-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
666-
file tests.
667-
668661
=head2 method r
669662
670663
Defined as:
@@ -675,9 +668,6 @@ Returns C<True> if the invocant is a path that exists and is accessible.
675668
The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the
676669
path points to a non-existent filesystem entity.
677670
678-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
679-
file tests.
680-
681671
=head2 method w
682672
683673
Defined as:
@@ -688,9 +678,6 @@ Returns C<True> if the invocant is a path that exists and is writable.
688678
The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the
689679
path points to a non-existent filesystem entity.
690680
691-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
692-
file tests.
693-
694681
=head2 method rw
695682
696683
Defined as:
@@ -701,9 +688,6 @@ Returns C<True> if the invocant is a path that exists and is readable and
701688
writable. The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist>
702689
if the path points to a non-existent filesystem entity.
703690
704-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
705-
file tests.
706-
707691
=head2 method x
708692
709693
Defined as:
@@ -714,9 +698,6 @@ Returns C<True> if the invocant is a path that exists and is executable.
714698
The method will L«C<fail>|/routine/fail» with C<X::IO::DoesNotExist> if the
715699
path points to a non-existent filesystem entity.
716700
717-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
718-
file tests.
719-
720701
=head2 method rwx
721702
722703
Defined as:
@@ -727,9 +708,6 @@ Returns C<True> if the invocant is a path that exists and is executable,
727708
readable, and writable. The method will L«C<fail>|/routine/fail» with
728709
C<X::IO::DoesNotExist> if the path points to a non-existent filesystem entity.
729710
730-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
731-
file tests.
732-
733711
=head2 method z
734712
735713
Defined as:
@@ -743,9 +721,6 @@ is dependent on the operating system. The method will L«C<fail>|/routine/fail»
743721
with C<X::IO::DoesNotExist> if the path points to a non-existent filesystem
744722
entity.
745723
746-
TIP: use L«smartmatch with Pairs|/type/Pair#method_ACCEPTS» to perform multiple
747-
file tests.
748-
749724
=head2 method sibling
750725
751726
Defined as:

0 commit comments

Comments
 (0)