Perl 随机数和随机密码的产生
#!/usr/bin/perl
#
# 0~1之间
#大范围
#整数
#offset
# 某范围间的随机整数 25,75
$random = int( rand( $Y-$X+1 ) ) + $X; #起止范围
$random = int( rand(51)) + 25; print "$random\n";
#随机密码
@chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(qin yang
$password = join("", @chars[ map { rand @chars } ( 1 .. 8 ) ]);
print "\t$password\n";
#从数组生成随机密码
@array=qw,323 dd ddae oiljef 43,;
$elt = $array[ rand @array ];
print "$elt\n";
$elt = $array[ int( rand(0+@array) ) ];
print "$elt\n";
#随机密码,任意长度
sub randomPassword {
my $password;
my $_rand;
my $password_length = $_[0];
my @chars = split(" ",
srand;
for (my $i=0; $i <= $password_length ;$i++) {
}
return $password;
}
#产生六位数的随机密码