Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- while (1)
- {
- print "What would you like to roll?\nFormat Ex. 1d20, 2d6, 1d4, etc...\n";
- my $input = <>;
- if ($input =~ /^(\d+)d(\d+)$/)
- {
- unless ($2)
- {
- print "d0 not supported.\n\n";
- next;
- }
- my $d = 0;
- $d += 1 + int(rand($2)) for (1..$1);
- print "you rolled $1 d$2 for: \n$d\n";
- }
- else
- {
- print "Invalid format or no input given.\n\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement