Skip to content

Commit 68e8cc4

Browse files
author
Jan-Olof Hendig
committed
printf is a method of IO::Handle
1 parent a547aff commit 68e8cc4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doc/Language/io.pod6

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ explicit encoding can be specified via the C<:enc> option:
7878
=for code :skip-test
7979
spurt "testfile", "latin1 text: äöüß", enc => "latin1";
8080
81-
Writing formatted strings to a file is not directly supported at the moment because function
82-
'printf' is not yet a method of C<IO::Handle>. However, as a work-around, one can use
83-
function 'sprintf' to assign a formatted string to a C<Str> object that can then be
84-
used with methods '.say' or '.print' as desired.
81+
To write formatted strings to a file, use the L<printf|/routine/printf> function
82+
of L<IO::Handle>.
83+
84+
=for code :skip-test
85+
my $fh = open "testfile", :w;
86+
$fh.printf("formatted data %04d\n", 42);
87+
$fh.close;
8588
8689
To append to a file, specify the C<:a> option when opening the file handle
8790
explicitly,

0 commit comments

Comments
 (0)