Skip to content

Commit

Permalink
Add example of file path analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Aug 13, 2022
1 parent 2e682ec commit 8f7b28a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doc/Language/io-guide.pod6
Expand Up @@ -63,6 +63,22 @@ However, don't be in a rush to stringify anything. Pass paths around as
L<IO::Path|/type/IO::Path> objects. All the routines that operate on paths
can handle them, so there's no need to convert them.
=head2 Path parts
Given a local file name, it's very easy to get its components.
For example, we have a file, "financial.data", in some
directory, "/usr/local/data". Use Raku to analyze its path:
=begin code
my $fname = "financial.data";
# Stringify the full path name
my $f = $fname.IO.absolute;
say $f; # OUTPUT: «/usr/local/data/financial.data␤»
# Stringify the path's parts:
say $f.IO.dirname; # OUTPUT: «/usr/local/data␤»
say $f.IO.basename; # OUTPUT: «financial.data␤»
=end code
=head2 Working with files
=head3 Writing into files
Expand Down

0 comments on commit 8f7b28a

Please sign in to comment.