September 2017
Beginner
402 pages
9h 52m
English
In the previous chapters, we have created many programs that print to the console and read data from it. Let us refresh some knowledge from Chapter 2, Writing Code, and create a program that asks for the user's name and greets them:
my $name = prompt 'What is your name? '; say "Hello, $name!"; note "Greeted $name at " ~ time;
Here, the prompt function prints the message and waits until the user enters a string. The string is saved in the $name variable, which is later interpolated in a string in double quotes. The note function prints the debugging message and logs the time of when the person was greeted.
In this program, Perl 6 uses two standard communication channels, the standard input stream (stdin for short) ...