eg/rlbasic
raw| 1 | #!/usr/bin/env perl |
| 2 | # |
| 3 | # rlbasic: A basic readline() loop example |
| 4 | # |
| 5 | # Copyright (C) 2024 Hiroo Hayashi |
| 6 | # |
| 7 | # Derived from: examples/rlbasic.c in the GNU Readline Library |
| 8 | |
| 9 | use strict; |
| 10 | use warnings; |
| 11 | use Term::ReadLine; |
| 12 | |
| 13 | my $t = new Term::ReadLine 'rlbasic'; |
| 14 | |
| 15 | while (1) { |
| 16 | my $input = $t->readline(''); |
| 17 | last unless defined $input; |
| 18 | print("$input\n"); |
| 19 | if ($input eq 'exit') { |
| 20 | last; |
| 21 | } |
| 22 | } |
| 23 | exit 0; |