#!/usr/bin/perl use warnings; use strict; my $up = "\e[A"; my @history = []; my $number = 10; print "Input the dice and modifier you want to roll like this: 2d9+100. To quit, press Ctrl-C.\n"; while (1) { my $dice = <>; chomp $dice; my @arr = split (/d/, $dice); if ($dice eq $up) { $dice = $history[-1]; } elsif ($dice =~ /\+/) { my @arr2 = split (/\+/, $arr[1]); $arr2[0]++; for my $i (1 .. $arr[0]) { print ((int(rand($arr2[0] - 1)) + 1 + $arr2[1]), "\n"); } } else { $arr[1]++; for my $i (1 .. $arr[0]) { print ((int(rand($arr[1] - 1)) + 1), "\n"); } } push @history, $dice; } #### Input the dice and modifier you want to roll like this: 2d9+100. To quit, press Ctrl-C. 2d9+100 109 101 ^[[A ^C