File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -78,10 +78,13 @@ explicit encoding can be specified via the C<:enc> option:
78
78
= for code :skip-test
79
79
spurt "testfile", "latin1 text: äöüß", enc => "latin1";
80
80
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;
85
88
86
89
To append to a file, specify the C < :a > option when opening the file handle
87
90
explicitly,
You can’t perform that action at this time.
0 commit comments