The say method

At first glance, the say method works like the print method and adds a new line character at the end. But this is not the full truth. Internally, say calls the gist method on the object it prints to get the textual representation of it.

For the data types such as strings and integers, their textual forms are straightforward. There will be no difference in the output for print and say in the following example:

my $str = 'String';
print $str, "\n";
say $str;

my $int = 42;
print $int, "\n";
say $int;

With more complex data structures, the behavior of the two methods is different. The output of the program is shown in the comments:

my @array = <10 20 30>; print @array, "\n"; # 10 20 30 say @array; # [10 20 30] my %hash = alpha ...

Get Perl 6 Deep Dive now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.