rl_readline#

Display a prompt, read one line with full editing, and return the entered string (or undef on EOF).

Synopsis#

while (defined (my $line = $term->readline('prompt> '))) {
    $term->addhistory($line) if $line =~ /\S/;
    last if $line eq 'quit';
}

The call blocks until the user presses Return. A bare Ctrl-D on an empty line returns undef. The returned string has its trailing newline already stripped, matching the underlying readline(3) C function. The prompt argument is optional; pass undef for none.