Skip to content

Commit fc1214e

Browse files
committed
Merge pull request #278 from mortie/patch-1
Some more documentation about put
2 parents 04a80a2 + 0eaa15c commit fc1214e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

doc/Language/faq.pod

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,21 @@ But don't do that. If the name is public, there is no downside to
356356
declaring it that way with C<$.x> since the external view is readonly
357357
by default, and you can still access it internally with C<$!x>.
358358
359-
=head2 How and why do C<say> and C<print> differ?
359+
=head2 How and why do C<say>, C<put> and C<print> differ?
360360
361-
The most obvious difference is that C<say> appends a newline at the
362-
end of the output, and C<print> does not.
361+
The most obvious difference is that C<say> and C<put> appends
362+
a newline at the end of the output, and C<print> does not.
363363
364-
But there is another difference: C<print> converts its arguments to
365-
a string by calling the C<Str> method on each item passed to, C<say>
366-
uses the C<gist> method instead. The former is meant for computers,
367-
the latter for human interpretation.
364+
But there is another difference: C<print> and C<put> converts its
365+
arguments to a string by calling the C<Str> method on each item
366+
passed to, C<say> uses the C<gist> method instead. The former
367+
is meant for computers, the latter for human interpretation.
368368
369369
Or phrased differently, C<$obj.Str> gives a string representation,
370370
C<$obj.gist> a short summary of that object suitable for fast recognition
371371
by the programmer, and C<$obj.perl> gives a Perlish representation.
372372
373-
For example type objects, also known as "undefined values", stringify
373+
Example: type objects, also known as "undefined values", stringify
374374
to an empty string and warn, whereas the C<gist> method returns the name
375375
of the type, followed by an empty pair of parenthesis (to indicate there's
376376
nothing in that value except the type).
@@ -380,8 +380,12 @@ nothing in that value except the type).
380380
say $x; # (Date)\n
381381
382382
So C<say> is optimized for debugging and display to people, C<print>
383-
is more suitable for producing output for other programs to consume.
384-
(Use C<put> if you want C<print> semantics with a newline.)
383+
and C<put> is more suitable for producing output for other programs
384+
to consume.
385+
386+
C<put> is thus sort of a hybrid between C<print> and C<say>;
387+
like C<print>, its output is suitable for other programs,
388+
and like C<say>, it adds a newline at the end of the output.
385389
386390
=head2 What's the difference between C<token> and C<rule> ?
387391

0 commit comments

Comments
 (0)