Ivanzhibin:
Please go back and edit your node to add code tags (<c>your code goes here</c>) to your post: It's pretty difficult to make sense of it.
I went ahead and reformatted some of it on my machine to see what you're doing, but didn't finish. I saw a couple of things that you'll want to learn before proceeding.
First: the point of a subroutine is to let you reuse code, rather than writing it over and over. Specifically, you don't need all the rand_string1 through rand_string8 subroutines. They all do the exact same thing. This does the same thing as the first section of your program:
my $string1 = rand_string();
my $string2 = rand_string();
my $string3 = rand_string();
my $string4 = rand_string();
my $string5 = rand_string();
my $string6 = rand_string();
my $string7 = rand_string();
my $string8 = rand_string();
sub rand_string {
my @chars = ('A'..'Z');
my $length = 0;
my $temp_string = '';
for (0..$length) {
$temp_string .= $chars[int rand @chars];
}
return $temp_string;
}
The variable name you use inside of your subroutine doesn't have to be related to the variable name outside of your subroutine.
Next, I don't know what you think this line does:
my $count1 = $string1 =~ tr/"a-z" || "A-Z"//;
But I'm pretty sure it doesn't do what you want. You'll want to read over the documentation for tr in the documentation (perldoc -f perlop).
I'll check back later and see how things are going.
...roboticus
When your only tool is a hammer, all problems look like your thumb. |