develooper Front page | perl.perl6.language | Postings from October 2018

Re: "put" vs "say"

Thread Previous
Parrot Raiser
October 21, 2018 17:41
Re: "put" vs "say"
Message ID:
Thanks for the suggestions. I ran a couple of tests:

my $data_list = 1..1001;
say $data_list;


real    0m0.357s
user    0m0.435s
sys     0m0.048s

my $data_list = 1..1001;
put $data_list;

produces the list of integers from 1 to 1001 (obviously a single string).

real    0m0.470s
user    0m0.452s
sys     0m0.058s

Changing the list to an array,

say produces
[1 2 3 4 5 6 (....) 98 99 100 ...]

real    0m0.435s
user    0m0.484s
sys     0m0.056s

put result is unchanged in

real    0m0.424s
user    0m0.445s
sys     0m0.068s

Further research is clearly required, as all good research reports say.

On 10/21/18, Timo Paulssen <> wrote:
> put is meant for machines, while say is meant for humans.
> this is implemented by having say call the .gist method and put calling
> the .Str method.
> Try using say and put on a list of a thousand elements or more and
> you'll see what I mean.
>   - Timo
> On 21/10/2018 18:29, Parrot Raiser wrote:
>> "put" and "say" seem to be redundant, but I'm sure there's a good
>> reason for having 2 output commands.
>> Would anyone care to comment on how they differ and why, or point to
>> an explanation?

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About