Skip to content

Commit 671e00e

Browse files
committed
improve examples
1 parent fe43e2e commit 671e00e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

doc/Type/IO/Path.pod6

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ Usage:
528528
529529
If you have a string - a path to something in the filesystem:
530530
531-
if "path/to/file".IO ~~ :e {
532-
say 'file exists';
531+
if "path/to/directory".IO ~~ :e & :d {
532+
say 'path exists and is a directory';
533533
}
534534
535535
my $file = "path/to/file";
@@ -547,9 +547,10 @@ If you already have an IO object in $file, either by creating one yourself,
547547
or by getting it from another subroutine, such as C<dir>,
548548
you can write this:
549549
550-
my $file = "path/to/file".IO;
551-
if $file ~~ :e {
552-
say 'file exists';
550+
my $path = "path/to/file".IO;
551+
given $path {
552+
when :f { say 'path is a file' }
553+
when :d { say 'path is a directory' }
553554
}
554555
555556
=head1 File timestamp retrieval

0 commit comments

Comments
 (0)