But it always returns a string with just $extension, and I have not a clue why. Any aid?sub random_filename { my($length_limit, $extension); # examples: $length_limit = +255, $extension = '.jpg' my($current_length, $random_filename); $length_limit = shift(); $extension = shift(); for ($current_length = 1; $current_length >= $length_limit; $curre +nt_length++) { $random_filename .= chr(int(rand(26) + 97)); # range from l +owercase a to lowercase z last() unless (int(rand($length_limit))); # 1/$length_l +imit chance of quitting the loop each run through } $random_filename .= $extension; return($random_filename); }
In reply to generating random filenames by Amoe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |