@@ -356,21 +356,21 @@ But don't do that. If the name is public, there is no downside to
356
356
declaring it that way with C < $.x > since the external view is readonly
357
357
by default, and you can still access it internally with C < $!x > .
358
358
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?
360
360
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.
363
363
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.
368
368
369
369
Or phrased differently, C < $obj.Str > gives a string representation,
370
370
C < $obj.gist > a short summary of that object suitable for fast recognition
371
371
by the programmer, and C < $obj.perl > gives a Perlish representation.
372
372
373
- For example type objects, also known as "undefined values", stringify
373
+ Example: type objects, also known as "undefined values", stringify
374
374
to an empty string and warn, whereas the C < gist > method returns the name
375
375
of the type, followed by an empty pair of parenthesis (to indicate there's
376
376
nothing in that value except the type).
@@ -380,8 +380,12 @@ nothing in that value except the type).
380
380
say $x; # (Date)\n
381
381
382
382
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.
385
389
386
390
= head2 What's the difference between C < token > and C < rule > ?
387
391
0 commit comments