Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use diagnostics;
- sub random_die_rolls($@)
- {
- my ( $numbers_of_rolls, @numbers_of_sides ) = @_;
- my @results;
- #This foreach loop dosent work!!!
- foreach my $num_sides( @numbers_of_sides )
- {
- my $total = 0;
- $total += 1 + int( rand( $num_sides) ) for 1 .. $numbers_of_rolls;
- print $total;
- push @results, $total;
- }
- print @results;
- return @results;
- }
- my @rolls = random_die_rolls 3;
- print join "\n", @rolls;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement