Help with perl script
Hello. This is my secound day learning perl. So I thought I would write a simple script to use an array and randomly choose one of the 26 availible letters which will be checked against what you wanted to find, then print how many times it took.
here is what I have to find one letter of your choosing. Code:
#!/usr/bin/perl For example, locating a string that is 2 letters, such as AB or ABC. Like maybe I would like to see how long it takes to randomly find my name 'JOHN'. Hope I provided enough info about how goal. |
Assuming you still want to find A, but want to generate random strings of random length from 1 to MAX_LEN characters, maybe something like this:
Code:
#!/usr/local/bin/perl |
sweet. Thanks a ton. Im going to change it around a little bit to suit my needs and to give me a little better idea about how it works.
|
Actually, int(rand(x)) returns an integer from 0 to x-1
Also (because I am a picky Perl programmer), I will point out you can write that for loop with something like this: Code:
$hold = join '', map $array[rand @array], (1..$string_length); |
All times are GMT -5. The time now is 10:59 AM. |