1.

Solve : Perl random and count?

Answer»

I have decided to START to learn a new programming language, which in this case if perl. I have got 6 numbers that get RANDOMLY printed on the screen and I want to be able to count how many times each number show up/get's randomly picked. My code is below of what I have done so far.

Code:

#!/usr/local/bin/perl

# VARIABLES
@counter = (1 .. 200);
@numbers = (1, 2, 3, 4, 5, 6);


for $i (@counter) {
my @numbers = (1, 2, 3, 4, 5, 6);
PRINT $numbers[int rand scalar @numbers], "\N";

}

Any help would be, well helpfull,
Tan_Za



Discussion

No Comment Found