in reply to How to add input history
#!/usr/bin/perl # http://perlmonks.org/?node_id=1122584 use Term::ReadLine; use strict; (my $term = new Term::ReadLine 'dierolling')->ornaments(",,,"); print "Input the dice and modifier you want to roll like this: 2d9+100 +. To quit, press Ctrl-C.\n"; while (1) { defined(my $dice = $term->readline('? ')) or last; 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");}}
This is only during a single run. If you want history to be persistent from one execution to the next, please say so.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to add input history
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 | |
by stevieb (Canon) on Apr 06, 2015 at 23:33 UTC | |
by stevieb (Canon) on Apr 06, 2015 at 23:25 UTC | |
|