Hello everyone, I just join here. So, I need help for homework. Here it.
Write a program that simulates the rolling of a die 6000 times and displays in a
tabular format the number of occurrences of each side of the die.
#!/usr/bin/perl
$roll = &rolldie;
@count = ();
@array = (1 .. 6000);
print "@array\n";
foreach (1..6000) {
$roll = $rolldie;
&rolldie;
print $roll;
push (@count, $roll);
&tally;
}
print "@count\n";
print "ROLL SCORE\n";
print "======================\n";
print sort (keys %tally), "\n";
print sort (values %tally), "\n";
########### subroutines begin here ##############
#### subroutine1 ###############################
sub rolldie {
return 1 + int(rand(6));
}
Did I wrong something. Pls let me know. Thanks