'Prompting for user input (like Perl's $inp=<>) in Raku
How do we do Perl's '
$inp=<>;
to prompt user a single line, in Raku ?
As lines(); keep on prompting a user input so not work identically
Please help clarify
Solution 1:[1]
to prompt user a single line, in Raku ?
The prompt function does this.
my $input = prompt; # No message
my $name = prompt 'Name: '; # Or with a message
Solution 2:[2]
See get, which is an alias for lines(1), or something pretty close to that.
It initially surprised me how hard it is to discover in Raku resources -- doc, design doc, chat logs, etc. But I guess <> and line are so overloaded that it's not that odd after all.
I've added a comment about get's (lack of) discoverability in the doc issues queue. It would be helpful to those working on the doc if you added another comment in the same issue saying where you'd looked to get (!) an answer to your Q.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jonathan Worthington |
| Solution 2 | raiph |
