Perl中生成随机字符串

From Yefu's notes
Jump to: navigation, search
sub randstr
{
 my $maxLenth=16;
 #my @a = (0..9,'$','%','a'..'z','A'..'Z','-','+','_');
 my @a = (0..9,'a'..'z','A'..'Z');
 my $password = join '', map { $a[int rand @a] } 0..($maxLenth-1);
 return $password;
}

<comments/>