zsl has asked for the wisdom of the Perl Monks concerning the following question:
I'm making a Dungeons & Dragons die-rolling program in which the user is asked for input over and over until Ctrl-C. The source code is here:
#!/usr/bin/perl print "Input the dice and modifier you want to roll like this: 2d9+100 +. To quit, press Ctrl-C.\n"; while (1) { my $dice = <>; my @arr = split (/d/, $dice); my @arr2 = split (/\+/, $arr[1]); for my $i (1 .. $arr[0]){ print ((int(rand($arr2[0] - 1)) + 1 + $arr2[1]), "\n");}}
I want to add input history to this program; that is, when a user presses the up-arrow, the program provides the last input, just like in interactive ksh/csh/bash. How would I go about this? $thanks++, zsl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to add input history
by PerlSufi (Friar) on Apr 06, 2015 at 17:31 UTC | |
|
Re: How to add input history
by stevieb (Canon) on Apr 06, 2015 at 17:45 UTC | |
by zsl (Novice) on Apr 10, 2015 at 22:34 UTC | |
by zsl (Novice) on Apr 11, 2015 at 00:07 UTC | |
|
Re: How to add input history
by pme (Monsignor) on Apr 06, 2015 at 17:33 UTC | |
|
Re: How to add input history
by jeffa (Bishop) on Apr 06, 2015 at 21:26 UTC | |
|
Re: How to add input history
by Anonymous Monk on Apr 06, 2015 at 20:02 UTC | |
by stevieb (Canon) on Apr 06, 2015 at 20:29 UTC | |
by Anonymous Monk on Apr 06, 2015 at 22:09 UTC | |
by stevieb (Canon) on Apr 06, 2015 at 22:40 UTC | |
by Anonymous Monk on Apr 06, 2015 at 23:08 UTC | |
|