Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perl 6's printf function doesn't yet work with a file
  • Loading branch information
tbrowder committed Aug 22, 2016
1 parent 95cd619 commit 4f433bb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions doc/Language/5to6-perlfunc.pod6
Expand Up @@ -978,22 +978,23 @@ L<Continue|/language/regexes#Continue>.
=item print
C<print> can be used as a function in Perl 6, defaulting to standard
C<print> can be used as a function in Perl 6, writing to standard
out. To use C<print> as a function with a filehandle I<instead> of
standard out, you need to put a colon after the filehandle. I. e.
C<print $fh: "Howdy!">. The use of the colon as an "invocant marker"
here is discussed at L<https://design.perl6.org/S03.html#line_4019>.
Alternately, you can use a method call: C<$fh.print("howdy!")>
standard out, you can use a method call: C<$fh.print("howdy!")>
=head2 printf
=item printf FILEHANDLE
=item printf FORMAT, LIST
=item printf
Works in Perl 6. For the formats, see the documentation for C<sprintf>.
Works in Perl 6, but only as a function writing to standard out. To
use for a file handle, one must create a formatted string using function C<sprintf>
and then pass the string to C<IO::Handle> method C<.say> or C<.print> as desired.
For the formats, see the documentation for C<sprintf>. For example:
my $fh = open "tmp.txt", :w;
$fh.say(sprintf("%d", 2));
=head2 prototype
Expand Down

0 comments on commit 4f433bb

Please sign in to comment.