一个简单的perl脚本用以生成6位随机数字,可基于此做稍稍修改,生成各种不同的随机字符串。
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- main();
- sub main
- {
- my $strlist = "0,1,2,3,4,5,6,7,8,9";
- my @list = split(',', $strlist);
- my $out = '';
- for (my $x=0; $x<6; $x++)
- {
- my $i = randnum();
- $out .= $list[$i];
- }
- print $out;
- }
- sub randnum
- {
- my $n = rand(10);
- my $m = int($n);
- return $m;
- }
转载于:https://blog.51cto.com/orzee/622465