Prompting for user input (like Perl's $inp=<>) in Raku

Viewed 141

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

2 Answers

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

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.

Related